mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	renamed subtree operations in context menu from "branch" to "subtree"
This commit is contained in:
		| @@ -86,21 +86,21 @@ const contextMenuOptions = { | |||||||
|         {title: "----"}, |         {title: "----"}, | ||||||
|         {title: "Edit branch prefix <kbd>F2</kbd>", cmd: "editBranchPrefix", uiIcon: "ui-icon-pencil"}, |         {title: "Edit branch prefix <kbd>F2</kbd>", cmd: "editBranchPrefix", uiIcon: "ui-icon-pencil"}, | ||||||
|         {title: "----"}, |         {title: "----"}, | ||||||
|         {title: "Protect branch", cmd: "protectBranch", uiIcon: "ui-icon-locked"}, |         {title: "Protect subtree", cmd: "protectSubtree", uiIcon: "ui-icon-locked"}, | ||||||
|         {title: "Unprotect branch", cmd: "unprotectBranch", uiIcon: "ui-icon-unlocked"}, |         {title: "Unprotect subtree", cmd: "unprotectSubtree", uiIcon: "ui-icon-unlocked"}, | ||||||
|         {title: "----"}, |         {title: "----"}, | ||||||
|         {title: "Copy / clone <kbd>Ctrl+C</kbd>", cmd: "copy", uiIcon: "ui-icon-copy"}, |         {title: "Copy / clone <kbd>Ctrl+C</kbd>", cmd: "copy", uiIcon: "ui-icon-copy"}, | ||||||
|         {title: "Cut <kbd>Ctrl+X</kbd>", cmd: "cut", uiIcon: "ui-icon-scissors"}, |         {title: "Cut <kbd>Ctrl+X</kbd>", cmd: "cut", uiIcon: "ui-icon-scissors"}, | ||||||
|         {title: "Paste into <kbd>Ctrl+V</kbd>", cmd: "pasteInto", uiIcon: "ui-icon-clipboard"}, |         {title: "Paste into <kbd>Ctrl+V</kbd>", cmd: "pasteInto", uiIcon: "ui-icon-clipboard"}, | ||||||
|         {title: "Paste after", cmd: "pasteAfter", uiIcon: "ui-icon-clipboard"}, |         {title: "Paste after", cmd: "pasteAfter", uiIcon: "ui-icon-clipboard"}, | ||||||
|         {title: "----"}, |         {title: "----"}, | ||||||
|         {title: "Export subtree", cmd: "exportSubTree", uiIcon: " ui-icon-arrowthick-1-ne", children: [ |         {title: "Export subtree", cmd: "exportSubtree", uiIcon: " ui-icon-arrowthick-1-ne", children: [ | ||||||
|             {title: "Native Tar", cmd: "exportSubTreeToTar"}, |             {title: "Native Tar", cmd: "exportSubtreeToTar"}, | ||||||
|             {title: "OPML", cmd: "exportSubTreeToOpml"} |             {title: "OPML", cmd: "exportSubtreeToOpml"} | ||||||
|         ]}, |         ]}, | ||||||
|         {title: "Import into branch (tar, opml)", cmd: "importBranch", uiIcon: "ui-icon-arrowthick-1-sw"}, |         {title: "Import into note (tar, opml)", cmd: "importIntoNote", uiIcon: "ui-icon-arrowthick-1-sw"}, | ||||||
|         {title: "----"}, |         {title: "----"}, | ||||||
|         {title: "Collapse branch <kbd>Alt+-</kbd>", cmd: "collapseBranch", uiIcon: "ui-icon-minus"}, |         {title: "Collapse subtree <kbd>Alt+-</kbd>", cmd: "collapseSubtree", uiIcon: "ui-icon-minus"}, | ||||||
|         {title: "Force note sync", cmd: "forceNoteSync", uiIcon: "ui-icon-refresh"}, |         {title: "Force note sync", cmd: "forceNoteSync", uiIcon: "ui-icon-refresh"}, | ||||||
|         {title: "Sort alphabetically <kbd>Alt+S</kbd>", cmd: "sortAlphabetically", uiIcon: " ui-icon-arrowthick-2-n-s"} |         {title: "Sort alphabetically <kbd>Alt+S</kbd>", cmd: "sortAlphabetically", uiIcon: " ui-icon-arrowthick-2-n-s"} | ||||||
|     ], |     ], | ||||||
| @@ -119,8 +119,8 @@ const contextMenuOptions = { | |||||||
|         $tree.contextmenu("enableEntry", "cut", isNotRoot); |         $tree.contextmenu("enableEntry", "cut", isNotRoot); | ||||||
|         $tree.contextmenu("enableEntry", "pasteAfter", clipboardIds.length > 0 && isNotRoot && parentNote.type !== 'search'); |         $tree.contextmenu("enableEntry", "pasteAfter", clipboardIds.length > 0 && isNotRoot && parentNote.type !== 'search'); | ||||||
|         $tree.contextmenu("enableEntry", "pasteInto", clipboardIds.length > 0 && note.type !== 'search'); |         $tree.contextmenu("enableEntry", "pasteInto", clipboardIds.length > 0 && note.type !== 'search'); | ||||||
|         $tree.contextmenu("enableEntry", "importBranch", note.type !== 'search'); |         $tree.contextmenu("enableEntry", "importIntoNote", note.type !== 'search'); | ||||||
|         $tree.contextmenu("enableEntry", "exportSubTree", note.type !== 'search'); |         $tree.contextmenu("enableEntry", "exportSubtree", note.type !== 'search'); | ||||||
|         $tree.contextmenu("enableEntry", "editBranchPrefix", isNotRoot && parentNote.type !== 'search'); |         $tree.contextmenu("enableEntry", "editBranchPrefix", isNotRoot && parentNote.type !== 'search'); | ||||||
|  |  | ||||||
|         // Activate node on right-click |         // Activate node on right-click | ||||||
| @@ -145,11 +145,11 @@ const contextMenuOptions = { | |||||||
|         else if (ui.cmd === "editBranchPrefix") { |         else if (ui.cmd === "editBranchPrefix") { | ||||||
|             branchPrefixDialog.showDialog(node); |             branchPrefixDialog.showDialog(node); | ||||||
|         } |         } | ||||||
|         else if (ui.cmd === "protectBranch") { |         else if (ui.cmd === "protectSubtree") { | ||||||
|             protectedSessionService.protectBranch(node.data.noteId, true); |             protectedSessionService.protectSubtree(node.data.noteId, true); | ||||||
|         } |         } | ||||||
|         else if (ui.cmd === "unprotectBranch") { |         else if (ui.cmd === "unprotectSubtree") { | ||||||
|             protectedSessionService.protectBranch(node.data.noteId, false); |             protectedSessionService.protectSubtree(node.data.noteId, false); | ||||||
|         } |         } | ||||||
|         else if (ui.cmd === "copy") { |         else if (ui.cmd === "copy") { | ||||||
|             copy(treeService.getSelectedNodes()); |             copy(treeService.getSelectedNodes()); | ||||||
| @@ -166,16 +166,16 @@ const contextMenuOptions = { | |||||||
|         else if (ui.cmd === "delete") { |         else if (ui.cmd === "delete") { | ||||||
|             treeChangesService.deleteNodes(treeService.getSelectedNodes(true)); |             treeChangesService.deleteNodes(treeService.getSelectedNodes(true)); | ||||||
|         } |         } | ||||||
|         else if (ui.cmd === "exportSubTreeToTar") { |         else if (ui.cmd === "exportSubtreeToTar") { | ||||||
|             exportService.exportSubTree(node.data.noteId, 'tar'); |             exportService.exportSubtree(node.data.noteId, 'tar'); | ||||||
|         } |         } | ||||||
|         else if (ui.cmd === "exportSubTreeToOpml") { |         else if (ui.cmd === "exportSubtreeToOpml") { | ||||||
|             exportService.exportSubTree(node.data.noteId, 'opml'); |             exportService.exportSubtree(node.data.noteId, 'opml'); | ||||||
|         } |         } | ||||||
|         else if (ui.cmd === "importBranch") { |         else if (ui.cmd === "importIntoNote") { | ||||||
|             exportService.importBranch(node.data.noteId); |             exportService.importIntoNote(node.data.noteId); | ||||||
|         } |         } | ||||||
|         else if (ui.cmd === "collapseBranch") { |         else if (ui.cmd === "collapseSubtree") { | ||||||
|             treeService.collapseTree(node); |             treeService.collapseTree(node); | ||||||
|         } |         } | ||||||
|         else if (ui.cmd === "forceNoteSync") { |         else if (ui.cmd === "forceNoteSync") { | ||||||
|   | |||||||
| @@ -3,7 +3,7 @@ import protectedSessionHolder from './protected_session_holder.js'; | |||||||
| import utils from './utils.js'; | import utils from './utils.js'; | ||||||
| import server from './server.js'; | import server from './server.js'; | ||||||
|  |  | ||||||
| function exportSubTree(noteId, format) { | function exportSubtree(noteId, format) { | ||||||
|     const url = utils.getHost() + "/api/notes/" + noteId + "/export/" + format + |     const url = utils.getHost() + "/api/notes/" + noteId + "/export/" + format + | ||||||
|         "?protectedSessionId=" + encodeURIComponent(protectedSessionHolder.getProtectedSessionId()); |         "?protectedSessionId=" + encodeURIComponent(protectedSessionHolder.getProtectedSessionId()); | ||||||
|  |  | ||||||
| @@ -12,7 +12,7 @@ function exportSubTree(noteId, format) { | |||||||
|  |  | ||||||
| let importNoteId; | let importNoteId; | ||||||
|  |  | ||||||
| function importBranch(noteId) { | function importIntoNote(noteId) { | ||||||
|     importNoteId = noteId; |     importNoteId = noteId; | ||||||
|  |  | ||||||
|     $("#import-upload").trigger('click'); |     $("#import-upload").trigger('click'); | ||||||
| @@ -35,6 +35,6 @@ $("#import-upload").change(async function() { | |||||||
| }); | }); | ||||||
|  |  | ||||||
| export default { | export default { | ||||||
|     exportSubTree, |     exportSubtree, | ||||||
|     importBranch |     importIntoNote | ||||||
| }; | }; | ||||||
| @@ -148,7 +148,7 @@ async function unprotectNoteAndSendToServer() { | |||||||
|     noteDetailService.setNoteBackgroundIfProtected(note); |     noteDetailService.setNoteBackgroundIfProtected(note); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function protectBranch(noteId, protect) { | async function protectSubtree(noteId, protect) { | ||||||
|     await ensureProtectedSession(true, true); |     await ensureProtectedSession(true, true); | ||||||
|  |  | ||||||
|     await server.put('notes/' + noteId + "/protect/" + (protect ? 1 : 0)); |     await server.put('notes/' + noteId + "/protect/" + (protect ? 1 : 0)); | ||||||
| @@ -172,7 +172,7 @@ export default { | |||||||
|     ensureProtectedSession, |     ensureProtectedSession, | ||||||
|     protectNoteAndSendToServer, |     protectNoteAndSendToServer, | ||||||
|     unprotectNoteAndSendToServer, |     unprotectNoteAndSendToServer, | ||||||
|     protectBranch, |     protectSubtree, | ||||||
|     ensureDialogIsClosed, |     ensureDialogIsClosed, | ||||||
|     enterProtectedSession, |     enterProtectedSession, | ||||||
|     leaveProtectedSession |     leaveProtectedSession | ||||||
|   | |||||||
| @@ -45,7 +45,7 @@ async function sortNotes(req) { | |||||||
|     await treeService.sortNotesAlphabetically(noteId); |     await treeService.sortNotesAlphabetically(noteId); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function protectBranch(req) { | async function protectSubtree(req) { | ||||||
|     const noteId = req.params.noteId; |     const noteId = req.params.noteId; | ||||||
|     const note = await repository.getNote(noteId); |     const note = await repository.getNote(noteId); | ||||||
|     const protect = !!parseInt(req.params.isProtected); |     const protect = !!parseInt(req.params.isProtected); | ||||||
| @@ -70,6 +70,6 @@ module.exports = { | |||||||
|     updateNote, |     updateNote, | ||||||
|     createNote, |     createNote, | ||||||
|     sortNotes, |     sortNotes, | ||||||
|     protectBranch, |     protectSubtree, | ||||||
|     setNoteTypeMime |     setNoteTypeMime | ||||||
| }; | }; | ||||||
| @@ -117,7 +117,7 @@ function register(app) { | |||||||
|     apiRoute(PUT, '/api/notes/:noteId', notesApiRoute.updateNote); |     apiRoute(PUT, '/api/notes/:noteId', notesApiRoute.updateNote); | ||||||
|     apiRoute(POST, '/api/notes/:parentNoteId/children', notesApiRoute.createNote); |     apiRoute(POST, '/api/notes/:parentNoteId/children', notesApiRoute.createNote); | ||||||
|     apiRoute(PUT, '/api/notes/:noteId/sort', notesApiRoute.sortNotes); |     apiRoute(PUT, '/api/notes/:noteId/sort', notesApiRoute.sortNotes); | ||||||
|     apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectBranch); |     apiRoute(PUT, '/api/notes/:noteId/protect/:isProtected', notesApiRoute.protectSubtree); | ||||||
|     apiRoute(PUT, /\/api\/notes\/(.*)\/type\/(.*)\/mime\/(.*)/, notesApiRoute.setNoteTypeMime); |     apiRoute(PUT, /\/api\/notes\/(.*)\/type\/(.*)\/mime\/(.*)/, notesApiRoute.setNoteTypeMime); | ||||||
|     apiRoute(GET, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.getNoteRevisions); |     apiRoute(GET, '/api/notes/:noteId/revisions', noteRevisionsApiRoute.getNoteRevisions); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -193,14 +193,14 @@ async function saveNoteRevision(note) { | |||||||
|  |  | ||||||
|     const revisionCutoff = dateUtils.dateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000)); |     const revisionCutoff = dateUtils.dateStr(new Date(now.getTime() - noteRevisionSnapshotTimeInterval * 1000)); | ||||||
|  |  | ||||||
|     const existingnoteRevisionId = await sql.getValue( |     const existingNoteRevisionId = await sql.getValue( | ||||||
|         "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND dateModifiedTo >= ?", [note.noteId, revisionCutoff]); |         "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND dateModifiedTo >= ?", [note.noteId, revisionCutoff]); | ||||||
|  |  | ||||||
|     const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.dateCreated).getTime(); |     const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.dateCreated).getTime(); | ||||||
|  |  | ||||||
|     if (note.type !== 'file' |     if (note.type !== 'file' | ||||||
|         && !await note.hasLabel('disableVersioning') |         && !await note.hasLabel('disableVersioning') | ||||||
|         && !existingnoteRevisionId |         && !existingNoteRevisionId | ||||||
|         && msSinceDateCreated >= noteRevisionSnapshotTimeInterval * 1000) { |         && msSinceDateCreated >= noteRevisionSnapshotTimeInterval * 1000) { | ||||||
|  |  | ||||||
|         await new NoteRevision({ |         await new NoteRevision({ | ||||||
|   | |||||||
| @@ -34,17 +34,17 @@ async function getExistingBranch(parentNoteId, childNoteId) { | |||||||
|  * Tree cycle can be created when cloning or when moving existing clone. This method should detect both cases. |  * Tree cycle can be created when cloning or when moving existing clone. This method should detect both cases. | ||||||
|  */ |  */ | ||||||
| async function checkTreeCycle(parentNoteId, childNoteId) { | async function checkTreeCycle(parentNoteId, childNoteId) { | ||||||
|     const subTreeNoteIds = []; |     const subtreeNoteIds = []; | ||||||
|  |  | ||||||
|     // we'll load the whole sub tree - because the cycle can start in one of the notes in the sub tree |     // we'll load the whole sub tree - because the cycle can start in one of the notes in the sub tree | ||||||
|     await loadSubTreeNoteIds(childNoteId, subTreeNoteIds); |     await loadSubtreeNoteIds(childNoteId, subtreeNoteIds); | ||||||
|  |  | ||||||
|     async function checkTreeCycleInner(parentNoteId) { |     async function checkTreeCycleInner(parentNoteId) { | ||||||
|         if (parentNoteId === 'root') { |         if (parentNoteId === 'root') { | ||||||
|             return true; |             return true; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (subTreeNoteIds.includes(parentNoteId)) { |         if (subtreeNoteIds.includes(parentNoteId)) { | ||||||
|             // while towards the root of the tree we encountered noteId which is already present in the subtree |             // while towards the root of the tree we encountered noteId which is already present in the subtree | ||||||
|             // joining parentNoteId with childNoteId would then clearly create a cycle |             // joining parentNoteId with childNoteId would then clearly create a cycle | ||||||
|             return false; |             return false; | ||||||
| @@ -68,13 +68,13 @@ async function getBranch(branchId) { | |||||||
|     return sql.getRow("SELECT * FROM branches WHERE branchId = ?", [branchId]); |     return sql.getRow("SELECT * FROM branches WHERE branchId = ?", [branchId]); | ||||||
| } | } | ||||||
|  |  | ||||||
| async function loadSubTreeNoteIds(parentNoteId, subTreeNoteIds) { | async function loadSubtreeNoteIds(parentNoteId, subtreeNoteIds) { | ||||||
|     subTreeNoteIds.push(parentNoteId); |     subtreeNoteIds.push(parentNoteId); | ||||||
|  |  | ||||||
|     const children = await sql.getColumn("SELECT noteId FROM branches WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]); |     const children = await sql.getColumn("SELECT noteId FROM branches WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]); | ||||||
|  |  | ||||||
|     for (const childNoteId of children) { |     for (const childNoteId of children) { | ||||||
|         await loadSubTreeNoteIds(childNoteId, subTreeNoteIds); |         await loadSubtreeNoteIds(childNoteId, subtreeNoteIds); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user