mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	add #newNotesOnTop, closes #3734
This commit is contained in:
		| @@ -22,17 +22,18 @@ const htmlSanitizer = require("./html_sanitizer"); | ||||
| const ValidationError = require("../errors/validation_error"); | ||||
| const noteTypesService = require("./note_types"); | ||||
|  | ||||
| function getNewNotePosition(parentNoteId) { | ||||
|     const note = becca.notes[parentNoteId]; | ||||
| function getNewNotePosition(parentNote) { | ||||
|     if (parentNote.hasLabel('newNotesOnTop')) { | ||||
|         const minNotePos = parentNote.getChildBranches() | ||||
|             .reduce((min, note) => Math.min(min, note.notePosition), 0); | ||||
|  | ||||
|     if (!note) { | ||||
|         throw new Error(`Can't find note ${parentNoteId}`); | ||||
|         return minNotePos - 10; | ||||
|     } else { | ||||
|         const maxNotePos = parentNote.getChildBranches() | ||||
|             .reduce((max, note) => Math.max(max, note.notePosition), 0); | ||||
|  | ||||
|         return maxNotePos + 10; | ||||
|     } | ||||
|  | ||||
|     const maxNotePos = note.getChildBranches() | ||||
|         .reduce((max, note) => Math.max(max, note.notePosition), 0); | ||||
|  | ||||
|     return maxNotePos + 10; | ||||
| } | ||||
|  | ||||
| function triggerNoteTitleChanged(note) { | ||||
| @@ -186,7 +187,7 @@ function createNewNote(params) { | ||||
|             branch = new BBranch({ | ||||
|                 noteId: note.noteId, | ||||
|                 parentNoteId: params.parentNoteId, | ||||
|                 notePosition: params.notePosition !== undefined ? params.notePosition : getNewNotePosition(params.parentNoteId), | ||||
|                 notePosition: params.notePosition !== undefined ? params.notePosition : getNewNotePosition(parentNote), | ||||
|                 prefix: params.prefix, | ||||
|                 isExpanded: !!params.isExpanded | ||||
|             }).save(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user