Skip to content

Build your personal knowledge base with Trilium Notes

Merge branch 'master' into next60

zadamb3c4c850dbeb
diff --cc src/services/notes.js
index aeb7ad6eb2,6dfa34cb04..84c497af93
--- a/src/services/notes.js
+++ b/src/services/notes.js
@@@ -21,19 -21,19 +21,20 @@@ const dayjs = require("dayjs")
const htmlSanitizer = require("./html_sanitizer");
const ValidationError = require("../errors/validation_error");
const noteTypesService = require("./note_types");
+const {attach} = require("jsdom/lib/jsdom/living/helpers/svg/basic-types.js");
- 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}`);
- }
-
- const maxNotePos = note.getChildBranches()
- .reduce((max, note) => Math.max(max, note.notePosition), 0);
+ return minNotePos - 10;
+ } else {
+ const maxNotePos = parentNote.getChildBranches()
+ .reduce((max, note) => Math.max(max, note.notePosition), 0);
- return maxNotePos + 10;
+ return maxNotePos + 10;
+ }
}
function triggerNoteTitleChanged(note) {