mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +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: "Edit branch prefix <kbd>F2</kbd>", cmd: "editBranchPrefix", uiIcon: "ui-icon-pencil"}, | ||||
|         {title: "----"}, | ||||
|         {title: "Protect branch", cmd: "protectBranch", uiIcon: "ui-icon-locked"}, | ||||
|         {title: "Unprotect branch", cmd: "unprotectBranch", uiIcon: "ui-icon-unlocked"}, | ||||
|         {title: "Protect subtree", cmd: "protectSubtree", uiIcon: "ui-icon-locked"}, | ||||
|         {title: "Unprotect subtree", cmd: "unprotectSubtree", uiIcon: "ui-icon-unlocked"}, | ||||
|         {title: "----"}, | ||||
|         {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: "Paste into <kbd>Ctrl+V</kbd>", cmd: "pasteInto", uiIcon: "ui-icon-clipboard"}, | ||||
|         {title: "Paste after", cmd: "pasteAfter", uiIcon: "ui-icon-clipboard"}, | ||||
|         {title: "----"}, | ||||
|         {title: "Export subtree", cmd: "exportSubTree", uiIcon: " ui-icon-arrowthick-1-ne", children: [ | ||||
|             {title: "Native Tar", cmd: "exportSubTreeToTar"}, | ||||
|             {title: "OPML", cmd: "exportSubTreeToOpml"} | ||||
|         {title: "Export subtree", cmd: "exportSubtree", uiIcon: " ui-icon-arrowthick-1-ne", children: [ | ||||
|             {title: "Native Tar", cmd: "exportSubtreeToTar"}, | ||||
|             {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: "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: "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", "pasteAfter", clipboardIds.length > 0 && isNotRoot && parentNote.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "pasteInto", clipboardIds.length > 0 && note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "importBranch", note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "exportSubTree", note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "importIntoNote", note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "exportSubtree", note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "editBranchPrefix", isNotRoot && parentNote.type !== 'search'); | ||||
|  | ||||
|         // Activate node on right-click | ||||
| @@ -145,11 +145,11 @@ const contextMenuOptions = { | ||||
|         else if (ui.cmd === "editBranchPrefix") { | ||||
|             branchPrefixDialog.showDialog(node); | ||||
|         } | ||||
|         else if (ui.cmd === "protectBranch") { | ||||
|             protectedSessionService.protectBranch(node.data.noteId, true); | ||||
|         else if (ui.cmd === "protectSubtree") { | ||||
|             protectedSessionService.protectSubtree(node.data.noteId, true); | ||||
|         } | ||||
|         else if (ui.cmd === "unprotectBranch") { | ||||
|             protectedSessionService.protectBranch(node.data.noteId, false); | ||||
|         else if (ui.cmd === "unprotectSubtree") { | ||||
|             protectedSessionService.protectSubtree(node.data.noteId, false); | ||||
|         } | ||||
|         else if (ui.cmd === "copy") { | ||||
|             copy(treeService.getSelectedNodes()); | ||||
| @@ -166,16 +166,16 @@ const contextMenuOptions = { | ||||
|         else if (ui.cmd === "delete") { | ||||
|             treeChangesService.deleteNodes(treeService.getSelectedNodes(true)); | ||||
|         } | ||||
|         else if (ui.cmd === "exportSubTreeToTar") { | ||||
|             exportService.exportSubTree(node.data.noteId, 'tar'); | ||||
|         else if (ui.cmd === "exportSubtreeToTar") { | ||||
|             exportService.exportSubtree(node.data.noteId, 'tar'); | ||||
|         } | ||||
|         else if (ui.cmd === "exportSubTreeToOpml") { | ||||
|             exportService.exportSubTree(node.data.noteId, 'opml'); | ||||
|         else if (ui.cmd === "exportSubtreeToOpml") { | ||||
|             exportService.exportSubtree(node.data.noteId, 'opml'); | ||||
|         } | ||||
|         else if (ui.cmd === "importBranch") { | ||||
|             exportService.importBranch(node.data.noteId); | ||||
|         else if (ui.cmd === "importIntoNote") { | ||||
|             exportService.importIntoNote(node.data.noteId); | ||||
|         } | ||||
|         else if (ui.cmd === "collapseBranch") { | ||||
|         else if (ui.cmd === "collapseSubtree") { | ||||
|             treeService.collapseTree(node); | ||||
|         } | ||||
|         else if (ui.cmd === "forceNoteSync") { | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import protectedSessionHolder from './protected_session_holder.js'; | ||||
| import utils from './utils.js'; | ||||
| import server from './server.js'; | ||||
|  | ||||
| function exportSubTree(noteId, format) { | ||||
| function exportSubtree(noteId, format) { | ||||
|     const url = utils.getHost() + "/api/notes/" + noteId + "/export/" + format + | ||||
|         "?protectedSessionId=" + encodeURIComponent(protectedSessionHolder.getProtectedSessionId()); | ||||
|  | ||||
| @@ -12,7 +12,7 @@ function exportSubTree(noteId, format) { | ||||
|  | ||||
| let importNoteId; | ||||
|  | ||||
| function importBranch(noteId) { | ||||
| function importIntoNote(noteId) { | ||||
|     importNoteId = noteId; | ||||
|  | ||||
|     $("#import-upload").trigger('click'); | ||||
| @@ -35,6 +35,6 @@ $("#import-upload").change(async function() { | ||||
| }); | ||||
|  | ||||
| export default { | ||||
|     exportSubTree, | ||||
|     importBranch | ||||
|     exportSubtree, | ||||
|     importIntoNote | ||||
| }; | ||||
| @@ -148,7 +148,7 @@ async function unprotectNoteAndSendToServer() { | ||||
|     noteDetailService.setNoteBackgroundIfProtected(note); | ||||
| } | ||||
|  | ||||
| async function protectBranch(noteId, protect) { | ||||
| async function protectSubtree(noteId, protect) { | ||||
|     await ensureProtectedSession(true, true); | ||||
|  | ||||
|     await server.put('notes/' + noteId + "/protect/" + (protect ? 1 : 0)); | ||||
| @@ -172,7 +172,7 @@ export default { | ||||
|     ensureProtectedSession, | ||||
|     protectNoteAndSendToServer, | ||||
|     unprotectNoteAndSendToServer, | ||||
|     protectBranch, | ||||
|     protectSubtree, | ||||
|     ensureDialogIsClosed, | ||||
|     enterProtectedSession, | ||||
|     leaveProtectedSession | ||||
|   | ||||
| @@ -45,7 +45,7 @@ async function sortNotes(req) { | ||||
|     await treeService.sortNotesAlphabetically(noteId); | ||||
| } | ||||
|  | ||||
| async function protectBranch(req) { | ||||
| async function protectSubtree(req) { | ||||
|     const noteId = req.params.noteId; | ||||
|     const note = await repository.getNote(noteId); | ||||
|     const protect = !!parseInt(req.params.isProtected); | ||||
| @@ -70,6 +70,6 @@ module.exports = { | ||||
|     updateNote, | ||||
|     createNote, | ||||
|     sortNotes, | ||||
|     protectBranch, | ||||
|     protectSubtree, | ||||
|     setNoteTypeMime | ||||
| }; | ||||
| @@ -117,7 +117,7 @@ function register(app) { | ||||
|     apiRoute(PUT, '/api/notes/:noteId', notesApiRoute.updateNote); | ||||
|     apiRoute(POST, '/api/notes/:parentNoteId/children', notesApiRoute.createNote); | ||||
|     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(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 existingnoteRevisionId = await sql.getValue( | ||||
|     const existingNoteRevisionId = await sql.getValue( | ||||
|         "SELECT noteRevisionId FROM note_revisions WHERE noteId = ? AND dateModifiedTo >= ?", [note.noteId, revisionCutoff]); | ||||
|  | ||||
|     const msSinceDateCreated = now.getTime() - dateUtils.parseDateTime(note.dateCreated).getTime(); | ||||
|  | ||||
|     if (note.type !== 'file' | ||||
|         && !await note.hasLabel('disableVersioning') | ||||
|         && !existingnoteRevisionId | ||||
|         && !existingNoteRevisionId | ||||
|         && msSinceDateCreated >= noteRevisionSnapshotTimeInterval * 1000) { | ||||
|  | ||||
|         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. | ||||
|  */ | ||||
| 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 | ||||
|     await loadSubTreeNoteIds(childNoteId, subTreeNoteIds); | ||||
|     await loadSubtreeNoteIds(childNoteId, subtreeNoteIds); | ||||
|  | ||||
|     async function checkTreeCycleInner(parentNoteId) { | ||||
|         if (parentNoteId === 'root') { | ||||
|             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 | ||||
|             // joining parentNoteId with childNoteId would then clearly create a cycle | ||||
|             return false; | ||||
| @@ -68,13 +68,13 @@ async function getBranch(branchId) { | ||||
|     return sql.getRow("SELECT * FROM branches WHERE branchId = ?", [branchId]); | ||||
| } | ||||
|  | ||||
| async function loadSubTreeNoteIds(parentNoteId, subTreeNoteIds) { | ||||
|     subTreeNoteIds.push(parentNoteId); | ||||
| async function loadSubtreeNoteIds(parentNoteId, subtreeNoteIds) { | ||||
|     subtreeNoteIds.push(parentNoteId); | ||||
|  | ||||
|     const children = await sql.getColumn("SELECT noteId FROM branches WHERE parentNoteId = ? AND isDeleted = 0", [parentNoteId]); | ||||
|  | ||||
|     for (const childNoteId of children) { | ||||
|         await loadSubTreeNoteIds(childNoteId, subTreeNoteIds); | ||||
|         await loadSubtreeNoteIds(childNoteId, subtreeNoteIds); | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user