Skip to content

Build your personal knowledge base with Trilium Notes

small fixes

zadama882ad41c5bb
diff --git a/db/migrations/0199__rename_ids.sql b/db/migrations/0199__rename_ids.sql
index 76b7e128f7..07859064b7 100644
--- a/db/migrations/0199__rename_ids.sql
+++ b/db/migrations/0199__rename_ids.sql
@@ -32,7 +32,7 @@ UPDATE notes SET noteId = '_hidden' WHERE noteId = 'hidden';
UPDATE note_contents SET noteId = '_hidden' WHERE noteId = 'hidden';
UPDATE note_revisions SET noteId = '_hidden' WHERE noteId = 'hidden';
UPDATE branches SET noteId = '_hidden' WHERE noteId = 'hidden';
-UPDATE branches SET branchId = '_hidden' WHERE branchId = 'hidden';
+UPDATE branches SET branchId = '_hidden', prefix = NULL WHERE branchId = 'hidden';
UPDATE branches SET parentNoteId = '_hidden' WHERE parentNoteId = 'hidden';
UPDATE attributes SET noteId = '_hidden' WHERE noteId = 'hidden';
UPDATE attributes SET value = '_hidden' WHERE type = 'relation' AND value = 'hidden';
diff --git a/src/public/app/doc_notes/hidden.html b/src/public/app/doc_notes/hidden.html
index 98e79fd93a..2174733857 100644
--- a/src/public/app/doc_notes/hidden.html
+++ b/src/public/app/doc_notes/hidden.html
@@ -1 +1,3 @@
-<p>Hidden tree is used to record various application-level data which can stay most of the time hidden from the user view.</p>
\ No newline at end of file
+<p>Hidden tree is used to record various application-level data which can stay most of the time hidden from the user view.</p>
+
+<p>Make sure you know what you're doing. Incorrect changes in this subtree might potentially crash the application.</p>
diff --git a/src/public/app/doc_notes/user_hidden.html b/src/public/app/doc_notes/user_hidden.html
new file mode 100644
index 0000000000..4925502446
--- /dev/null
+++ b/src/public/app/doc_notes/user_hidden.html
@@ -0,0 +1 @@
+<p>This note serves as a subtree reserved for data produced by user scripts which should otherwise not freely create data in the hidden subtree.</p>
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js
index 99a2ca523a..5bfa8c65ba 100644
--- a/src/public/app/widgets/note_tree.js
+++ b/src/public/app/widgets/note_tree.js
@@ -371,7 +371,15 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
},
beforeActivate: (event, data) => {
// hidden subtree is hidden hackily, prevent activating it e.g. by keyboard
- return hoistedNoteService.getHoistedNoteId() === '_hidden' || data.node.data.noteId !== '_hidden';
+
+ if (hoistedNoteService.getHoistedNoteId() === '_hidden') {
+ // if we're hoisted in hidden subtree, we want to avoid crossing to "visible" tree,
+ // which could happen via UP key from hidden root (to another top level note)
+ return data.node.data.noteId === '_hidden' || data.node.getParent().data.noteId !== 'root';
+ }
+
+ // we're not hoisted to hidden subtree, the only way to cross is via DOWN key to the hidden root
+ return data.node.data.noteId !== '_hidden';
},
activate: async (event, data) => {
// click event won't propagate so let's close context menu manually
diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.js
index eb125b1387..b93fbc2b35 100644
--- a/src/services/hidden_subtree.js
+++ b/src/services/hidden_subtree.js
@@ -20,7 +20,8 @@ const HIDDEN_SUBTREE_DEFINITION = {
// over tree when it's in the middle
notePosition: 999_999_999,
attributes: [
- { type: 'label', name: 'excludeFromNoteMap', isInheritable: true }
+ { type: 'label', name: 'excludeFromNoteMap', isInheritable: true },
+ { type: 'label', name: 'docName', value: 'hidden' }
],
children: [
{
@@ -47,7 +48,7 @@ const HIDDEN_SUBTREE_DEFINITION = {
id: '_share',
title: 'Shared Notes',
type: 'doc',
- attributes: [ { type: 'label', name: 'docName', value: '_share' } ]
+ attributes: [ { type: 'label', name: 'docName', value: 'share' } ]
},
{
id: '_bulkAction',
@@ -67,7 +68,8 @@ const HIDDEN_SUBTREE_DEFINITION = {
// place for user scripts hidden stuff (scripts should not create notes directly under hidden root)
id: '_userHidden',
title: 'User Hidden',
- type: 'text',
+ type: 'doc',
+ attributes: [ { type: 'label', name: 'docName', value: 'user_hidden' } ]
},
{
id: LBTPL_ROOT,