mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	focus created note
This commit is contained in:
		| @@ -3,6 +3,7 @@ import noteCreateService from "./note_create.js"; | |||||||
| import treeService from "./tree.js"; | import treeService from "./tree.js"; | ||||||
| import hoistedNoteService from "./hoisted_note.js"; | import hoistedNoteService from "./hoisted_note.js"; | ||||||
| import Component from "../widgets/component.js"; | import Component from "../widgets/component.js"; | ||||||
|  | import ws from "./ws.js"; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * This class contains command executors which logically belong to the NoteTree widget, but for better user experience |  * This class contains command executors which logically belong to the NoteTree widget, but for better user experience | ||||||
| @@ -27,14 +28,20 @@ export default class MainTreeExecutors extends Component { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     async createNoteIntoCommand() { |     async createNoteIntoCommand() { | ||||||
|         const note = appContext.tabManager.getActiveTabNote(); |         const activeNote = appContext.tabManager.getActiveTabNote(); | ||||||
|  |  | ||||||
|         if (note) { |         if (!activeNote) { | ||||||
|             await noteCreateService.createNote(note.noteId, { |             return; | ||||||
|                 isProtected: note.isProtected, |  | ||||||
|                 saveSelection: false |  | ||||||
|             }); |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         const {note} = await noteCreateService.createNote(activeNote.noteId, { | ||||||
|  |             isProtected: activeNote.isProtected, | ||||||
|  |             saveSelection: false | ||||||
|  |         }); | ||||||
|  |  | ||||||
|  |         await ws.waitForMaxKnownSyncId(); | ||||||
|  |  | ||||||
|  |         appContext.tabManager.getActiveTabContext().setNote(note.noteId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     async createNoteAfterCommand() { |     async createNoteAfterCommand() { | ||||||
| @@ -46,11 +53,15 @@ export default class MainTreeExecutors extends Component { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         await noteCreateService.createNote(parentNoteId, { |         const {note} = await noteCreateService.createNote(parentNoteId, { | ||||||
|             target: 'after', |             target: 'after', | ||||||
|             targetBranchId: node.data.branchId, |             targetBranchId: node.data.branchId, | ||||||
|             isProtected: isProtected, |             isProtected: isProtected, | ||||||
|             saveSelection: true |             saveSelection: true | ||||||
|         }); |         }); | ||||||
|  |  | ||||||
|  |         await ws.waitForMaxKnownSyncId(); | ||||||
|  |  | ||||||
|  |         appContext.tabManager.getActiveTabContext().setNote(note.noteId); | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Reference in New Issue
	
	Block a user