Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
added "hoistedInbox" label
zadam98f02c3c9ad0
diff --git a/src/public/app/widgets/attribute_widgets/attribute_detail.js b/src/public/app/widgets/attribute_widgets/attribute_detail.jsindex fefcc047ef..7ca7a05da6 100644--- a/src/public/app/widgets/attribute_widgets/attribute_detail.js+++ b/src/public/app/widgets/attribute_widgets/attribute_detail.js@@ -196,7 +196,16 @@ const ATTR_HELP = {"iconClass": "value of this label is added as a CSS class to the icon on the tree which can help visually distinguish the notes in the tree. Example might be bx bx-home - icons are taken from boxicons. Can be used in template notes.","pageSize": "number of items per page in note listing","customRequestHandler": 'see <a href="javascript:" data-help-page="Custom request handler">Custom request handler</a>',- "customResourceProvider": 'see <a href="javascript:" data-help-page="Custom request handler">Custom request handler</a>'+ "customResourceProvider": 'see <a href="javascript:" data-help-page="Custom request handler">Custom request handler</a>',+ "widget": "marks this note as a custom widget which will be added to the Trilium component tree",+ "workspace": "marks this note as a workspace which allows easy hoisting",+ "workspaceIconClass": "defines box icon CSS class which will be used in tab when hoisted to this note",+ "workspaceTabBackgroundColor": "CSS color used in the note tab when hoisted to this note",+ "searchHome": "new search notes will be created as children of this note",+ "hoistedSearchHome": "new search notes will be created as children of this note when hoisted to some ancestor of this note",+ "inbox": "default inbox location for new notes",+ "hoistedInbox": "default inbox location for new notes when hoisted to some ancestor of this note",+ "sqlConsoleHome": "default location of SQL console notes",},"relation": {"runOnNoteCreation": "executes when note is created on backend",diff --git a/src/routes/api/date_notes.js b/src/routes/api/date_notes.jsindex 03c4ccee91..b28ad3aa77 100644--- a/src/routes/api/date_notes.js+++ b/src/routes/api/date_notes.js@@ -9,8 +9,27 @@ const cls = require('../../services/cls');const repository = require('../../services/repository');function getInboxNote(req) {- return attributeService.getNoteWithLabel('inbox')- || dateNoteService.getDateNote(req.params.date);+ const hoistedNote = getHoistedNote();++ let inbox;++ if (hoistedNote) {+ ([inbox] = hoistedNote.getDescendantNotesWithLabel('hoistedInbox'));++ if (!inbox) {+ ([inbox] = hoistedNote.getDescendantNotesWithLabel('inbox'));+ }++ if (!inbox) {+ inbox = hoistedNote;+ }+ }+ else {+ inbox = attributeService.getNoteWithLabel('inbox')+ || dateNoteService.getDateNote(req.params.date);+ }++ return inbox;}function getDateNote(req) {@@ -66,27 +85,18 @@ function createSearchNote(req) {const searchString = params.searchString || "";let ancestorNoteId = params.ancestorNoteId;- const hoistedNote = cls.getHoistedNoteId() && cls.getHoistedNoteId() !== 'root'- ? repository.getNote(cls.getHoistedNoteId())- : null;+ const hoistedNote = getHoistedNote();let searchHome;if (hoistedNote) {([searchHome] = hoistedNote.getDescendantNotesWithLabel('hoistedSearchHome'));- }-- if (!searchHome) {- const today = dateUtils.localNowDate();- searchHome = attributeService.getNoteWithLabel('searchHome')- || dateNoteService.getDateNote(today);- }-- if (hoistedNote) {+ if (!searchHome) {+ ([searchHome] = hoistedNote.getDescendantNotesWithLabel('searchHome'));+ }- if (!hoistedNote.getDescendantNoteIds().includes(searchHome.noteId)) {- // otherwise the note would be saved outside of the hoisted context which is weird+ if (!searchHome) {searchHome = hoistedNote;}@@ -94,6 +104,12 @@ function createSearchNote(req) {ancestorNoteId = hoistedNote.noteId;}}+ else {+ const today = dateUtils.localNowDate();++ searchHome = attributeService.getNoteWithLabel('searchHome')+ || dateNoteService.getDateNote(today);+ }const {note} = noteService.createNewNote({parentNoteId: searchHome.noteId,@@ -112,6 +128,12 @@ function createSearchNote(req) {return note;}+function getHoistedNote() {+ return cls.getHoistedNoteId() && cls.getHoistedNoteId() !== 'root'+ ? repository.getNote(cls.getHoistedNoteId())+ : null;+}+module.exports = {getInboxNote,getDateNote,diff --git a/src/services/attributes.js b/src/services/attributes.jsindex 3a684adbc7..ae78130f8d 100644--- a/src/services/attributes.js+++ b/src/services/attributes.js@@ -37,6 +37,7 @@ const BUILTIN_ATTRIBUTES = [{ type: 'label', name: 'workspaceIconClass' },{ type: 'label', name: 'workspaceTabBackgroundColor' },{ type: 'label', name: 'searchHome' },+ { type: 'label', name: 'hoistedInbox' },{ type: 'label', name: 'hoistedSearchHome' },{ type: 'label', name: 'sqlConsoleHome' },{ type: 'label', name: 'datePattern' },