mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
Merge remote-tracking branch 'origin/master' into next60
This commit is contained in:
commit
ecd2a5cbac
@ -185,6 +185,7 @@ div.ui-tooltip {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-menu {
|
.dropdown-menu {
|
||||||
|
border: 1px solid var(--dropdown-border-color);
|
||||||
color: var(--menu-text-color) !important;
|
color: var(--menu-text-color) !important;
|
||||||
background-color: var(--menu-background-color) !important;
|
background-color: var(--menu-background-color) !important;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
--main-background-color: #333;
|
--main-background-color: #333;
|
||||||
--main-text-color: #ccc;
|
--main-text-color: #ccc;
|
||||||
--main-border-color: #aaa;
|
--main-border-color: #aaa;
|
||||||
|
--dropdown-border-color: #555;
|
||||||
|
|
||||||
--accented-background-color: #555;
|
--accented-background-color: #555;
|
||||||
--more-accented-background-color: #777;
|
--more-accented-background-color: #777;
|
||||||
|
@ -20,6 +20,7 @@ html {
|
|||||||
--main-background-color: white;
|
--main-background-color: white;
|
||||||
--main-text-color: black;
|
--main-text-color: black;
|
||||||
--main-border-color: #ccc;
|
--main-border-color: #ccc;
|
||||||
|
--dropdown-border-color: #ccc;
|
||||||
|
|
||||||
--accented-background-color: #f5f5f5;
|
--accented-background-color: #f5f5f5;
|
||||||
--more-accented-background-color: #ddd;
|
--more-accented-background-color: #ddd;
|
||||||
|
@ -3,9 +3,12 @@
|
|||||||
const becca = require("../../becca/becca");
|
const becca = require("../../becca/becca");
|
||||||
const { JSDOM } = require("jsdom");
|
const { JSDOM } = require("jsdom");
|
||||||
const NotFoundError = require("../../errors/not_found_error");
|
const NotFoundError = require("../../errors/not_found_error");
|
||||||
|
function buildDescendantCountMap(noteIdsToCount) {
|
||||||
|
if (!Array.isArray(noteIdsToCount)) {
|
||||||
|
throw new Error('noteIdsToCount: type error');
|
||||||
|
}
|
||||||
|
|
||||||
function buildDescendantCountMap() {
|
const noteIdToCountMap = Object.create(null);
|
||||||
const noteIdToCountMap = {};
|
|
||||||
|
|
||||||
function getCount(noteId) {
|
function getCount(noteId) {
|
||||||
if (!(noteId in noteIdToCountMap)) {
|
if (!(noteId in noteIdToCountMap)) {
|
||||||
@ -24,12 +27,12 @@ function buildDescendantCountMap() {
|
|||||||
|
|
||||||
return noteIdToCountMap[noteId];
|
return noteIdToCountMap[noteId];
|
||||||
}
|
}
|
||||||
|
noteIdsToCount.forEach((noteId) => {
|
||||||
getCount('root');
|
getCount(noteId);
|
||||||
|
});
|
||||||
|
|
||||||
return noteIdToCountMap;
|
return noteIdToCountMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {BNote} note
|
* @param {BNote} note
|
||||||
* @param {int} depth
|
* @param {int} depth
|
||||||
@ -119,7 +122,9 @@ function getLinkMap(req) {
|
|||||||
noteIds.add(noteId);
|
noteIds.add(noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
const notes = Array.from(noteIds).map(noteId => {
|
const noteIdsArray = Array.from(noteIds)
|
||||||
|
|
||||||
|
const notes = noteIdsArray.map(noteId => {
|
||||||
const note = becca.getNote(noteId);
|
const note = becca.getNote(noteId);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -155,7 +160,7 @@ function getLinkMap(req) {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
notes: notes,
|
notes: notes,
|
||||||
noteIdToDescendantCountMap: buildDescendantCountMap(),
|
noteIdToDescendantCountMap: buildDescendantCountMap(noteIdsArray),
|
||||||
links: links
|
links: links
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -209,7 +214,7 @@ function getTreeMap(req) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const noteIdToDescendantCountMap = buildDescendantCountMap();
|
const noteIdToDescendantCountMap = buildDescendantCountMap(Array.from(noteIds));
|
||||||
|
|
||||||
updateDescendantCountMapForSearch(noteIdToDescendantCountMap, subtree.relationships);
|
updateDescendantCountMapForSearch(noteIdToDescendantCountMap, subtree.relationships);
|
||||||
|
|
||||||
|
@ -137,13 +137,13 @@ function BackendScriptApi(currentNote, apiParams) {
|
|||||||
this.getNoteWithLabel = attributeService.getNoteWithLabel;
|
this.getNoteWithLabel = attributeService.getNoteWithLabel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there's no branch between note and parent note, create one. Otherwise, do nothing.
|
* If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.
|
||||||
*
|
*
|
||||||
* @method
|
* @method
|
||||||
* @param {string} noteId
|
* @param {string} noteId
|
||||||
* @param {string} parentNoteId
|
* @param {string} parentNoteId
|
||||||
* @param {string} prefix - if branch will be created between note and parent note, set this prefix
|
* @param {string} prefix - if branch will be created between note and parent note, set this prefix
|
||||||
* @returns {void}
|
* @returns {{branch: BBranch|null}}
|
||||||
*/
|
*/
|
||||||
this.ensureNoteIsPresentInParent = cloningService.ensureNoteIsPresentInParent;
|
this.ensureNoteIsPresentInParent = cloningService.ensureNoteIsPresentInParent;
|
||||||
|
|
||||||
|
@ -61,15 +61,15 @@ function cloneNoteToBranch(noteId, parentBranchId, prefix) {
|
|||||||
|
|
||||||
function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) {
|
function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) {
|
||||||
if (isNoteDeleted(noteId)) {
|
if (isNoteDeleted(noteId)) {
|
||||||
return { success: false, message: `Note '${noteId}' is deleted.` };
|
return { branch: null, success: false, message: `Note '${noteId}' is deleted.` };
|
||||||
} else if (isNoteDeleted(parentNoteId)) {
|
} else if (isNoteDeleted(parentNoteId)) {
|
||||||
return { success: false, message: `Note '${parentNoteId}' is deleted.` };
|
return { branch: null, success: false, message: `Note '${parentNoteId}' is deleted.` };
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentNote = becca.getNote(parentNoteId);
|
const parentNote = becca.getNote(parentNoteId);
|
||||||
|
|
||||||
if (parentNote.type === 'search') {
|
if (parentNote.type === 'search') {
|
||||||
return { success: false, message: "Can't clone into a search note" };
|
return { branch: null, success: false, message: "Can't clone into a search note" };
|
||||||
}
|
}
|
||||||
|
|
||||||
const validationResult = treeService.validateParentChild(parentNoteId, noteId);
|
const validationResult = treeService.validateParentChild(parentNoteId, noteId);
|
||||||
@ -87,7 +87,7 @@ function ensureNoteIsPresentInParent(noteId, parentNoteId, prefix) {
|
|||||||
|
|
||||||
log.info(`Ensured note '${noteId}' is in parent note '${parentNoteId}' with prefix '${branch.prefix}'`);
|
log.info(`Ensured note '${noteId}' is in parent note '${parentNoteId}' with prefix '${branch.prefix}'`);
|
||||||
|
|
||||||
return { success: true };
|
return { branch: branch, success: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
function ensureNoteIsAbsentFromParent(noteId, parentNoteId) {
|
function ensureNoteIsAbsentFromParent(noteId, parentNoteId) {
|
||||||
|
@ -8,12 +8,12 @@ const becca = require('../becca/becca');
|
|||||||
|
|
||||||
function validateParentChild(parentNoteId, childNoteId, branchId = null) {
|
function validateParentChild(parentNoteId, childNoteId, branchId = null) {
|
||||||
if (['root', '_hidden', '_share', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(childNoteId)) {
|
if (['root', '_hidden', '_share', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(childNoteId)) {
|
||||||
return { success: false, message: `Cannot change this note's location.`};
|
return { branch: null, success: false, message: `Cannot change this note's location.`};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentNoteId === 'none') {
|
if (parentNoteId === 'none') {
|
||||||
// this shouldn't happen
|
// this shouldn't happen
|
||||||
return { success: false, message: `Cannot move anything into 'none' parent.` };
|
return { branch: null, success: false, message: `Cannot move anything into 'none' parent.` };
|
||||||
}
|
}
|
||||||
|
|
||||||
const existing = becca.getBranchFromChildAndParent(childNoteId, parentNoteId);
|
const existing = becca.getBranchFromChildAndParent(childNoteId, parentNoteId);
|
||||||
@ -23,6 +23,7 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
|
|||||||
const childNote = becca.getNote(childNoteId);
|
const childNote = becca.getNote(childNoteId);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
branch: existing,
|
||||||
success: false,
|
success: false,
|
||||||
message: `Note "${childNote.title}" note already exists in the "${parentNote.title}".`
|
message: `Note "${childNote.title}" note already exists in the "${parentNote.title}".`
|
||||||
};
|
};
|
||||||
@ -30,6 +31,7 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
|
|||||||
|
|
||||||
if (wouldAddingBranchCreateCycle(parentNoteId, childNoteId)) {
|
if (wouldAddingBranchCreateCycle(parentNoteId, childNoteId)) {
|
||||||
return {
|
return {
|
||||||
|
branch: null,
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Moving/cloning note here would create cycle.'
|
message: 'Moving/cloning note here would create cycle.'
|
||||||
};
|
};
|
||||||
@ -37,12 +39,13 @@ function validateParentChild(parentNoteId, childNoteId, branchId = null) {
|
|||||||
|
|
||||||
if (parentNoteId !== '_lbBookmarks' && becca.getNote(parentNoteId).type === 'launcher') {
|
if (parentNoteId !== '_lbBookmarks' && becca.getNote(parentNoteId).type === 'launcher') {
|
||||||
return {
|
return {
|
||||||
|
branch: null,
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Launcher note cannot have any children.'
|
message: 'Launcher note cannot have any children.'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return { success: true };
|
return { branch: null, success: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user