mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
Merge branch 'master' into next60
This commit is contained in:
commit
b3c4c850db
@ -242,7 +242,8 @@ const ATTR_HELP = {
|
|||||||
"keepCurrentHoisting": "Opening this link won't change hoisting even if the note is not displayable in the current hoisted subtree.",
|
"keepCurrentHoisting": "Opening this link won't change hoisting even if the note is not displayable in the current hoisted subtree.",
|
||||||
"executeButton": "Title of the button which will execute the current code note",
|
"executeButton": "Title of the button which will execute the current code note",
|
||||||
"executeDescription": "Longer description of the current code note displayed together with the execute button",
|
"executeDescription": "Longer description of the current code note displayed together with the execute button",
|
||||||
"excludeFromNoteMap": "Notes with this label will be hidden from the Note Map"
|
"excludeFromNoteMap": "Notes with this label will be hidden from the Note Map",
|
||||||
|
"newNotesOnTop": "New notes will be created at the top of the parent note, not on the bottom."
|
||||||
},
|
},
|
||||||
"relation": {
|
"relation": {
|
||||||
"runOnNoteCreation": "executes when note is created on backend. Use this relation if you want to run the script for all notes created under a specific subtree. In that case, create it on the subtree root note and make it inheritable. A new note created within the subtree (any depth) will trigger the script.",
|
"runOnNoteCreation": "executes when note is created on backend. Use this relation if you want to run the script for all notes created under a specific subtree. In that case, create it on the subtree root note and make it inheritable. A new note created within the subtree (any depth) will trigger the script.",
|
||||||
|
@ -475,7 +475,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
const noteId = 'al_' + opts.id;
|
const noteId = 'al_' + opts.id;
|
||||||
|
|
||||||
const launcherNote =
|
const launcherNote =
|
||||||
becca.getNote(opts.id) ||
|
becca.getNote(noteId) ||
|
||||||
specialNotesService.createLauncher({
|
specialNotesService.createLauncher({
|
||||||
noteId: noteId,
|
noteId: noteId,
|
||||||
parentNoteId: parentNoteId,
|
parentNoteId: parentNoteId,
|
||||||
@ -514,7 +514,7 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
if (opts.icon) {
|
if (opts.icon) {
|
||||||
launcherNote.setLabel('iconClass', `bx ${opts.icon}`);
|
launcherNote.setLabel('iconClass', `bx ${opts.icon}`);
|
||||||
} else {
|
} else {
|
||||||
launcherNote.removeLabel('keyboardShortcut');
|
launcherNote.removeLabel('iconClass');
|
||||||
}
|
}
|
||||||
|
|
||||||
return {note: launcherNote};
|
return {note: launcherNote};
|
||||||
|
@ -62,6 +62,7 @@ module.exports = [
|
|||||||
{ type: 'label', name: 'keepCurrentHoisting'},
|
{ type: 'label', name: 'keepCurrentHoisting'},
|
||||||
{ type: 'label', name: 'executeButton'},
|
{ type: 'label', name: 'executeButton'},
|
||||||
{ type: 'label', name: 'executeDescription'},
|
{ type: 'label', name: 'executeDescription'},
|
||||||
|
{ type: 'label', name: 'newNotesOnTop'},
|
||||||
|
|
||||||
// relation names
|
// relation names
|
||||||
{ type: 'relation', name: 'internalLink' },
|
{ type: 'relation', name: 'internalLink' },
|
||||||
|
@ -23,17 +23,18 @@ const ValidationError = require("../errors/validation_error");
|
|||||||
const noteTypesService = require("./note_types");
|
const noteTypesService = require("./note_types");
|
||||||
const {attach} = require("jsdom/lib/jsdom/living/helpers/svg/basic-types.js");
|
const {attach} = require("jsdom/lib/jsdom/living/helpers/svg/basic-types.js");
|
||||||
|
|
||||||
function getNewNotePosition(parentNoteId) {
|
function getNewNotePosition(parentNote) {
|
||||||
const note = becca.notes[parentNoteId];
|
if (parentNote.hasLabel('newNotesOnTop')) {
|
||||||
|
const minNotePos = parentNote.getChildBranches()
|
||||||
|
.reduce((min, note) => Math.min(min, note.notePosition), 0);
|
||||||
|
|
||||||
if (!note) {
|
return minNotePos - 10;
|
||||||
throw new Error(`Can't find note ${parentNoteId}`);
|
} 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) {
|
function triggerNoteTitleChanged(note) {
|
||||||
@ -187,7 +188,7 @@ function createNewNote(params) {
|
|||||||
branch = new BBranch({
|
branch = new BBranch({
|
||||||
noteId: note.noteId,
|
noteId: note.noteId,
|
||||||
parentNoteId: params.parentNoteId,
|
parentNoteId: params.parentNoteId,
|
||||||
notePosition: params.notePosition !== undefined ? params.notePosition : getNewNotePosition(params.parentNoteId),
|
notePosition: params.notePosition !== undefined ? params.notePosition : getNewNotePosition(parentNote),
|
||||||
prefix: params.prefix,
|
prefix: params.prefix,
|
||||||
isExpanded: !!params.isExpanded
|
isExpanded: !!params.isExpanded
|
||||||
}).save();
|
}).save();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user