diff --git a/docs/backend_api/AbstractEntity.html b/docs/backend_api/AbstractEntity.html
index 2e07d3086..abff0dbe9 100644
--- a/docs/backend_api/AbstractEntity.html
+++ b/docs/backend_api/AbstractEntity.html
@@ -985,7 +985,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/Attribute.html b/docs/backend_api/Attribute.html
index 28e49bde4..449fb9eac 100644
--- a/docs/backend_api/Attribute.html
+++ b/docs/backend_api/Attribute.html
@@ -94,7 +94,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -205,7 +205,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -336,7 +336,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -404,7 +404,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -472,7 +472,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -540,7 +540,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -608,7 +608,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -676,7 +676,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -744,7 +744,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -1176,7 +1176,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -1370,7 +1370,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -1564,7 +1564,7 @@ and relation (representing named relationship between source and target note)Source:
@@ -1898,7 +1898,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/BackendScriptApi.html b/docs/backend_api/BackendScriptApi.html
index c80876aac..fb74b0d73 100644
--- a/docs/backend_api/BackendScriptApi.html
+++ b/docs/backend_api/BackendScriptApi.html
@@ -185,7 +185,7 @@
Source:
@@ -735,7 +735,7 @@
Source:
@@ -1743,7 +1743,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2460,7 +2460,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -2566,7 +2566,7 @@ JSON MIME type. See also createNewNote() for more options.
Source:
@@ -5150,7 +5150,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5258,7 +5258,7 @@ if some action needs to happen on only one specific instance.
Source:
@@ -5850,7 +5850,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -5971,6 +5971,8 @@ This method looks similar to toggleNoteInParent() but differs because we're look
+ Deprecated:
+
@@ -5983,7 +5985,7 @@ This method looks similar to toggleNoteInParent() but differs because we're look
Source:
@@ -6345,7 +6347,7 @@ exists, then we'll use that transaction.
Source:
@@ -6500,7 +6502,7 @@ exists, then we'll use that transaction.
Source:
@@ -6568,7 +6570,7 @@ exists, then we'll use that transaction.
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/Branch.html b/docs/backend_api/Branch.html
index 85a98fb5c..1151de586 100644
--- a/docs/backend_api/Branch.html
+++ b/docs/backend_api/Branch.html
@@ -31,7 +31,10 @@
Branch()
Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple
-parents.
+parents.
+
+Note that you should not rely on the branch's identity, since it can change easily with a note's move.
+Always check noteId instead.
@@ -94,7 +97,7 @@ parents.
Source:
@@ -268,7 +271,7 @@ parents.
Source:
@@ -326,7 +329,7 @@ parents.
Source:
@@ -394,7 +397,7 @@ parents.
Source:
@@ -460,7 +463,7 @@ of deletion should not act as a clone.
Source:
@@ -528,7 +531,7 @@ of deletion should not act as a clone.
Source:
@@ -596,7 +599,7 @@ of deletion should not act as a clone.
Source:
@@ -654,7 +657,7 @@ of deletion should not act as a clone.
Source:
@@ -722,7 +725,7 @@ of deletion should not act as a clone.
Source:
@@ -790,7 +793,7 @@ of deletion should not act as a clone.
Source:
@@ -858,7 +861,7 @@ of deletion should not act as a clone.
Source:
@@ -1210,7 +1213,7 @@ of deletion should not act as a clone.
Source:
@@ -1904,7 +1907,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/EtapiToken.html b/docs/backend_api/EtapiToken.html
index 5f7b1e1e5..a528c2e76 100644
--- a/docs/backend_api/EtapiToken.html
+++ b/docs/backend_api/EtapiToken.html
@@ -1455,7 +1455,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html
index 2c9c217f3..35153382b 100644
--- a/docs/backend_api/Note.html
+++ b/docs/backend_api/Note.html
@@ -1226,7 +1226,7 @@ See addLabel, addRelation for more specific methods.
Source:
@@ -1513,7 +1513,7 @@ See addLabel, addRelation for more specific methods.
Source:
@@ -1692,7 +1692,7 @@ returned.
Source:
@@ -1927,7 +1927,7 @@ returned.
Source:
@@ -2127,7 +2127,7 @@ returned.
Source:
@@ -2389,7 +2389,7 @@ returned.
Source:
@@ -2495,7 +2495,7 @@ returned.
Source:
@@ -7411,7 +7411,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7615,7 +7615,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -7811,7 +7811,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9306,7 +9306,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -10228,7 +10228,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -10408,7 +10408,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -10588,7 +10588,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -10783,7 +10783,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -11015,7 +11015,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -11195,7 +11195,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -11355,7 +11355,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -11597,7 +11597,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -11808,7 +11808,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -12019,7 +12019,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -12065,7 +12065,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/NoteRevision.html b/docs/backend_api/NoteRevision.html
index 5bb9a2eb3..51b0ff5e4 100644
--- a/docs/backend_api/NoteRevision.html
+++ b/docs/backend_api/NoteRevision.html
@@ -2168,7 +2168,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/Option.html b/docs/backend_api/Option.html
index f31eaf5e9..57f1da0aa 100644
--- a/docs/backend_api/Option.html
+++ b/docs/backend_api/Option.html
@@ -1313,7 +1313,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/RecentNote.html b/docs/backend_api/RecentNote.html
index 62c311b5e..6578477ae 100644
--- a/docs/backend_api/RecentNote.html
+++ b/docs/backend_api/RecentNote.html
@@ -1245,7 +1245,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/becca_entities_abstract_entity.js.html b/docs/backend_api/becca_entities_abstract_entity.js.html
index b7b47377a..4b266040c 100644
--- a/docs/backend_api/becca_entities_abstract_entity.js.html
+++ b/docs/backend_api/becca_entities_abstract_entity.js.html
@@ -203,7 +203,7 @@ module.exports = AbstractEntity;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/becca_entities_attribute.js.html b/docs/backend_api/becca_entities_attribute.js.html
index dbf8a63ba..a374f1d37 100644
--- a/docs/backend_api/becca_entities_attribute.js.html
+++ b/docs/backend_api/becca_entities_attribute.js.html
@@ -33,6 +33,7 @@ const AbstractEntity = require("./abstract_entity");
const sql = require("../../services/sql");
const dateUtils = require("../../services/date_utils");
const promotedAttributeDefinitionParser = require("../../services/promoted_attribute_definition_parser");
+const {sanitizeAttributeName} = require("../../services/sanitize_attribute_name");
/**
* Attribute is an abstract concept which has two real uses - label (key - value pair)
@@ -91,8 +92,6 @@ class Attribute extends AbstractEntity {
}
init() {
- this.validate();
-
if (this.attributeId) {
this.becca.attributes[this.attributeId] = this;
}
@@ -208,6 +207,8 @@ class Attribute extends AbstractEntity {
beforeSaving() {
this.validate();
+ this.name = sanitizeAttributeName(this.name);
+
if (!this.value) {
// null value isn't allowed
this.value = "";
@@ -267,7 +268,7 @@ module.exports = Attribute;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/becca_entities_branch.js.html b/docs/backend_api/becca_entities_branch.js.html
index 36f0cfa45..5e2bd010f 100644
--- a/docs/backend_api/becca_entities_branch.js.html
+++ b/docs/backend_api/becca_entities_branch.js.html
@@ -30,7 +30,6 @@
const Note = require('./note');
const AbstractEntity = require("./abstract_entity");
-const sql = require("../../services/sql");
const dateUtils = require("../../services/date_utils");
const utils = require("../../services/utils");
const TaskContext = require("../../services/task_context");
@@ -41,6 +40,9 @@ const log = require("../../services/log");
* Branch represents a relationship between a child note and its parent note. Trilium allows a note to have multiple
* parents.
*
+ * Note that you should not rely on the branch's identity, since it can change easily with a note's move.
+ * Always check noteId instead.
+ *
* @extends AbstractEntity
*/
class Branch extends AbstractEntity {
@@ -157,7 +159,7 @@ class Branch extends AbstractEntity {
* @returns {boolean}
*/
get isWeak() {
- return ['_share', 'lbBookmarks'].includes(this.parentNoteId);
+ return ['_share', '_lbBookmarks'].includes(this.parentNoteId);
}
/**
@@ -239,7 +241,7 @@ class Branch extends AbstractEntity {
let maxNotePos = 0;
for (const childBranch of this.parentNote.getChildBranches()) {
- if (maxNotePos < childBranch.notePosition && childBranch.branchId !== '_hidden') {
+ if (maxNotePos < childBranch.notePosition && childBranch.noteId !== '_hidden') {
maxNotePos = childBranch.notePosition;
}
}
@@ -293,7 +295,7 @@ module.exports = Branch;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/becca_entities_etapi_token.js.html b/docs/backend_api/becca_entities_etapi_token.js.html
index 064d6494b..1c3e98802 100644
--- a/docs/backend_api/becca_entities_etapi_token.js.html
+++ b/docs/backend_api/becca_entities_etapi_token.js.html
@@ -114,7 +114,7 @@ module.exports = EtapiToken;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/becca_entities_note.js.html b/docs/backend_api/becca_entities_note.js.html
index 689030bf5..aacf52e87 100644
--- a/docs/backend_api/becca_entities_note.js.html
+++ b/docs/backend_api/becca_entities_note.js.html
@@ -915,7 +915,7 @@ class Note extends AbstractEntity {
/**
* @returns {{notes: Note[], relationships: Array.<{parentNoteId: string, childNoteId: string}>}}
*/
- getSubtree({includeArchived = true, resolveSearch = false} = {}) {
+ getSubtree({includeArchived = true, includeHidden = false, resolveSearch = false} = {}) {
const noteSet = new Set();
const relationships = []; // list of tuples parentNoteId -> childNoteId
@@ -931,8 +931,7 @@ class Note extends AbstractEntity {
}
function addSubtreeNotesInner(note, parentNote = null) {
- // share can be removed after 0.57 since it will be put under hidden
- if (note.noteId === '_hidden' || note.noteId === '_share') {
+ if (note.noteId === '_hidden' && !includeHidden) {
return;
}
@@ -1070,6 +1069,10 @@ class Note extends AbstractEntity {
return false;
}
+ isInHiddenSubtree() {
+ return this.noteId === '_hidden' || this.hasAncestor('_hidden');
+ }
+
getTargetRelations() {
return this.targetRelations;
}
@@ -1468,7 +1471,7 @@ module.exports = Note;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/becca_entities_note_revision.js.html b/docs/backend_api/becca_entities_note_revision.js.html
index 701317705..816bac361 100644
--- a/docs/backend_api/becca_entities_note_revision.js.html
+++ b/docs/backend_api/becca_entities_note_revision.js.html
@@ -229,7 +229,7 @@ module.exports = NoteRevision;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/becca_entities_option.js.html b/docs/backend_api/becca_entities_option.js.html
index f63984cec..cbd6a639b 100644
--- a/docs/backend_api/becca_entities_option.js.html
+++ b/docs/backend_api/becca_entities_option.js.html
@@ -83,7 +83,7 @@ module.exports = Option;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/becca_entities_recent_note.js.html b/docs/backend_api/becca_entities_recent_note.js.html
index 5d6268cb2..f8c6007d4 100644
--- a/docs/backend_api/becca_entities_recent_note.js.html
+++ b/docs/backend_api/becca_entities_recent_note.js.html
@@ -71,7 +71,7 @@ module.exports = RecentNote;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/global.html b/docs/backend_api/global.html
index a50f15612..df505dcb5 100644
--- a/docs/backend_api/global.html
+++ b/docs/backend_api/global.html
@@ -95,6 +95,330 @@
+
+ Methods
+
+
+
+
+
+
+
+ SortConfig(parentNoteId, sortConfigopt )
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name
+
+
+ Type
+
+
+ Attributes
+
+
+
+
+ Description
+
+
+
+
+
+
+
+
+ parentNoteId
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ this note's child notes will be sorted
+
+
+
+
+
+
+ sortConfig
+
+
+
+
+
+SortConfig
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties:
+
+
+
+
+
+
+
+ Name
+
+
+ Type
+
+
+ Attributes
+
+
+
+ Default
+
+
+ Description
+
+
+
+
+
+
+
+
+ sortBy
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+
+
+
+ 'title', 'dateCreated', 'dateModified' or a label name
+ see https://github.com/zadam/trilium/wiki/Sorting for details.
+
+
+
+
+
+
+ reverse
+
+
+
+
+
+boolean
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+ foldersFirst
+
+
+
+
+
+boolean
+
+
+
+
+
+
+
+
+ <optional>
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+ /**
+Sort child notes of a given note.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1468,7 +1792,7 @@
Source:
@@ -1498,7 +1822,7 @@
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/index.html b/docs/backend_api/index.html
index afc8c4960..5f75f0c21 100644
--- a/docs/backend_api/index.html
+++ b/docs/backend_api/index.html
@@ -50,7 +50,7 @@
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/module-sql.html b/docs/backend_api/module-sql.html
index 58ca58289..5f1fdfe81 100644
--- a/docs/backend_api/module-sql.html
+++ b/docs/backend_api/module-sql.html
@@ -1294,7 +1294,7 @@
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/services_backend_script_api.js.html b/docs/backend_api/services_backend_script_api.js.html
index 77cbc836e..2209b292b 100644
--- a/docs/backend_api/services_backend_script_api.js.html
+++ b/docs/backend_api/services_backend_script_api.js.html
@@ -420,10 +420,32 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* @method
+ * @deprecated - use sortNotes instead
* @param {string} parentNoteId - this note's child notes will be sorted
*/
this.sortNotesByTitle = parentNoteId => treeService.sortNotes(parentNoteId);
+ /**
+ * @typedef {Object} SortConfig
+ * @property {string} [sortBy] - 'title', 'dateCreated', 'dateModified' or a label name
+ * see https://github.com/zadam/trilium/wiki/Sorting for details.
+ * @property {boolean} [reverse=false]
+ * @property {boolean} [foldersFirst=false]
+
+ /**
+ * Sort child notes of a given note.
+ *
+ * @method
+ * @param {string} parentNoteId - this note's child notes will be sorted
+ * @param {SortConfig} [sortConfig]
+ */
+ this.sortNotes = (parentNoteId, sortConfig = {}) => treeService.sortNotes(
+ parentNoteId,
+ sortConfig.sortBy || "title",
+ !!sortConfig.reverse,
+ !!sortConfig.foldersFirst
+ );
+
/**
* This method finds note by its noteId and prefix and either sets it to the given parentNoteId
* or removes the branch (if parentNoteId is not given).
@@ -521,12 +543,12 @@ function BackendScriptApi(currentNote, apiParams) {
if (opts.type === 'customWidget' && !opts.widgetNoteId) { throw new Error("widgetNoteId is mandatory for launchers of type 'customWidget'"); }
const parentNoteId = !!opts.isVisible ? '_lbVisibleLaunchers' : '_lbAvailableLaunchers';
- const actualId = 'al_' + opts.id;
+ const noteId = 'al_' + opts.id;
const launcherNote =
becca.getNote(opts.id) ||
specialNotesService.createLauncher({
- id: actualId,
+ noteId: noteId,
parentNoteId: parentNoteId,
launcherType: opts.type,
}).note;
@@ -588,7 +610,7 @@ module.exports = BackendScriptApi;
- Modules Classes
+ Modules Classes Global
diff --git a/docs/backend_api/services_sql.js.html b/docs/backend_api/services_sql.js.html
index 91b2d3863..809fd1349 100644
--- a/docs/backend_api/services_sql.js.html
+++ b/docs/backend_api/services_sql.js.html
@@ -404,7 +404,7 @@ module.exports = {
- Modules Classes
+ Modules Classes Global
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html
index 6a35fdec0..efb32f107 100644
--- a/docs/frontend_api/NoteShort.html
+++ b/docs/frontend_api/NoteShort.html
@@ -2582,7 +2582,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5400,7 +5400,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5513,7 +5513,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5619,7 +5619,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6903,7 +6903,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6987,7 +6987,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -7093,7 +7093,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.html
index 32fef2a2e..4e24579e6 100644
--- a/docs/frontend_api/entities_note_short.js.html
+++ b/docs/frontend_api/entities_note_short.js.html
@@ -738,6 +738,10 @@ class NoteShort {
return false;
}
+ isInHiddenSubtree() {
+ return this.noteId === '_hidden' || this.hasAncestor('_hidden');
+ }
+
/**
* @deprecated NOOP
*/
diff --git a/src/services/backend_script_api.js b/src/services/backend_script_api.js
index cdeabe212..477a9a629 100644
--- a/src/services/backend_script_api.js
+++ b/src/services/backend_script_api.js
@@ -392,10 +392,32 @@ function BackendScriptApi(currentNote, apiParams) {
/**
* @method
+ * @deprecated - use sortNotes instead
* @param {string} parentNoteId - this note's child notes will be sorted
*/
this.sortNotesByTitle = parentNoteId => treeService.sortNotes(parentNoteId);
+ /**
+ * @typedef {Object} SortConfig
+ * @property {string} [sortBy] - 'title', 'dateCreated', 'dateModified' or a label name
+ * see https://github.com/zadam/trilium/wiki/Sorting for details.
+ * @property {boolean} [reverse=false]
+ * @property {boolean} [foldersFirst=false]
+
+ /**
+ * Sort child notes of a given note.
+ *
+ * @method
+ * @param {string} parentNoteId - this note's child notes will be sorted
+ * @param {SortConfig} [sortConfig]
+ */
+ this.sortNotes = (parentNoteId, sortConfig = {}) => treeService.sortNotes(
+ parentNoteId,
+ sortConfig.sortBy || "title",
+ !!sortConfig.reverse,
+ !!sortConfig.foldersFirst
+ );
+
/**
* This method finds note by its noteId and prefix and either sets it to the given parentNoteId
* or removes the branch (if parentNoteId is not given).