mirror of
https://github.com/zadam/trilium.git
synced 2025-10-27 16:26:31 +01:00
create new sortNotes backend API method and deprecate old sortNotesByTitle
This commit is contained in:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user