From 724f99f17ce516af9c9115c7d4b1dedcaf598443 Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 21 Dec 2022 16:11:00 +0100 Subject: [PATCH] add prefix "_" to "named" IDs --- bin/tpl/anonymize-database.sql | 2 +- db/migrations/0199__rename_ids.sql | 49 ++++++++ db/migrations/0199__rename_noteIds.sql | 35 ------ .../0201__move_share_under_hidden.sql | 2 +- ...202__move_global_note_map_under_hidden.sql | 3 +- ...__delete_search_and_sql_console_history.js | 4 +- .../0207__rename_search_and_sql_console.sql | 4 +- .../0208__remove_archived_from_hidden.js | 2 +- package-lock.json | 1 - src/becca/entities/branch.js | 4 +- src/becca/entities/note.js | 4 +- src/public/app/components/entrypoints.js | 2 +- src/public/app/components/note_context.js | 6 +- .../app/components/root_command_executor.js | 12 +- src/public/app/components/tab_manager.js | 2 +- src/public/app/entities/note_short.js | 8 +- src/public/app/menus/launcher_context_menu.js | 8 +- src/public/app/services/branches.js | 10 +- src/public/app/services/hoisted_note.js | 2 +- src/public/app/services/keyboard_actions.js | 4 +- src/public/app/services/note_list_renderer.js | 2 +- src/public/app/services/tree.js | 2 +- src/public/app/widgets/bookmark_buttons.js | 2 +- src/public/app/widgets/bookmark_switch.js | 2 +- .../widgets/containers/launcher_container.js | 2 +- .../app/widgets/dialogs/bulk_actions.js | 6 +- .../widgets/floating_buttons/code_buttons.js | 2 +- src/public/app/widgets/icon_list.js | 4 +- src/public/app/widgets/note_title.js | 2 +- src/public/app/widgets/note_tree.js | 20 +-- .../ribbon_widgets/search_definition.js | 4 +- src/public/app/widgets/shared_info.js | 4 +- src/public/app/widgets/shared_switch.js | 10 +- src/routes/api/bulk_action.js | 2 +- src/services/anonymization.js | 2 +- src/services/cloning.js | 4 +- src/services/export/zip.js | 2 +- src/services/hidden_subtree.js | 114 ++++++++++-------- src/services/hoisted_note.js | 4 +- src/services/notes.js | 4 +- src/services/search/services/search.js | 2 +- src/services/special_notes.js | 27 +++-- src/services/tree.js | 4 +- src/share/routes.js | 2 +- src/share/share_root.js | 2 +- src/views/share/page.ejs | 2 +- test-etapi/create-entities.http | 6 +- test-etapi/delete-cloned-branch.http | 2 +- test-etapi/delete-note-with-all-branches.http | 2 +- 49 files changed, 215 insertions(+), 192 deletions(-) create mode 100644 db/migrations/0199__rename_ids.sql delete mode 100644 db/migrations/0199__rename_noteIds.sql diff --git a/bin/tpl/anonymize-database.sql b/bin/tpl/anonymize-database.sql index bcd506f82..c99e56e7a 100644 --- a/bin/tpl/anonymize-database.sql +++ b/bin/tpl/anonymize-database.sql @@ -1,6 +1,6 @@ UPDATE etapi_tokens SET tokenHash = 'API token hash value'; -UPDATE notes SET title = 'title' WHERE title NOT IN ('root', 'hidden', 'share'); +UPDATE notes SET title = 'title' WHERE title NOT IN ('root', '_hidden', '_share'); UPDATE note_contents SET content = 'text' WHERE content IS NOT NULL; UPDATE note_revisions SET title = 'title'; UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL; diff --git a/db/migrations/0199__rename_ids.sql b/db/migrations/0199__rename_ids.sql new file mode 100644 index 000000000..76b7e128f --- /dev/null +++ b/db/migrations/0199__rename_ids.sql @@ -0,0 +1,49 @@ +UPDATE notes SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE note_contents SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE note_revisions SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE branches SET branchId = '_globalNoteMap' WHERE branchId = 'globalnotemap'; +UPDATE branches SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE branches SET parentNoteId = '_globalNoteMap' WHERE parentNoteId = 'globalnotemap'; +UPDATE attributes SET noteId = '_globalNoteMap' WHERE noteId = 'globalnotemap'; +UPDATE attributes SET value = '_globalNoteMap' WHERE type = 'relation' AND value = 'globalnotemap'; +UPDATE entity_changes SET entityId = '_globalNoteMap' WHERE entityId = 'globalnotemap'; + +UPDATE notes SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; +UPDATE note_contents SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; +UPDATE note_revisions SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; +UPDATE branches SET branchId = '_bulkAction' WHERE branchId = 'bulkaction'; +UPDATE branches SET parentNoteId = '_bulkAction' WHERE parentNoteId = 'bulkaction'; +UPDATE branches SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; +UPDATE attributes SET noteId = '_bulkAction' WHERE noteId = 'bulkaction'; +UPDATE attributes SET value = '_bulkAction' WHERE type = 'relation' AND value = 'bulkaction'; +UPDATE entity_changes SET entityId = '_bulkAction' WHERE entityId = 'bulkaction'; + +UPDATE notes SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; +UPDATE note_contents SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; +UPDATE note_revisions SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; +UPDATE branches SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; +UPDATE branches SET branchId = '_sqlConsole' WHERE branchId = 'sqlconsole'; +UPDATE branches SET parentNoteId = '_sqlConsole' WHERE parentNoteId = 'sqlconsole'; +UPDATE attributes SET noteId = '_sqlConsole' WHERE noteId = 'sqlconsole'; +UPDATE attributes SET value = '_sqlConsole' WHERE type = 'relation' AND value = 'sqlconsole'; +UPDATE entity_changes SET entityId = '_sqlConsole' WHERE entityId = 'sqlconsole'; + +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 parentNoteId = '_hidden' WHERE parentNoteId = 'hidden'; +UPDATE attributes SET noteId = '_hidden' WHERE noteId = 'hidden'; +UPDATE attributes SET value = '_hidden' WHERE type = 'relation' AND value = 'hidden'; +UPDATE entity_changes SET entityId = '_hidden' WHERE entityId = 'hidden'; + +UPDATE notes SET noteId = '_search' WHERE noteId = 'search'; +UPDATE note_contents SET noteId = '_search' WHERE noteId = 'search'; +UPDATE note_revisions SET noteId = '_search' WHERE noteId = 'search'; +UPDATE branches SET noteId = '_search' WHERE noteId = 'search'; +UPDATE branches SET branchId = '_search' WHERE branchId = 'search'; +UPDATE branches SET parentNoteId = '_search' WHERE parentNoteId = 'search'; +UPDATE attributes SET noteId = '_search' WHERE noteId = 'search'; +UPDATE attributes SET value = '_search' WHERE type = 'relation' AND value = 'search'; +UPDATE entity_changes SET entityId = '_search' WHERE entityId = 'search'; diff --git a/db/migrations/0199__rename_noteIds.sql b/db/migrations/0199__rename_noteIds.sql deleted file mode 100644 index 675f6d0c4..000000000 --- a/db/migrations/0199__rename_noteIds.sql +++ /dev/null @@ -1,35 +0,0 @@ -UPDATE notes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE notes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE notes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE note_contents SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE note_contents SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE note_contents SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE note_revisions SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE note_revisions SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE note_revisions SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE branches SET branchId = 'globalNoteMap' WHERE branchId = 'globalnotemap'; -UPDATE branches SET branchId = 'bulkAction' WHERE branchId = 'bulkaction'; -UPDATE branches SET branchId = 'sqlConsole' WHERE branchId = 'sqlconsole'; - -UPDATE branches SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE branches SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE branches SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE branches SET parentNoteId = 'globalNoteMap' WHERE parentNoteId = 'globalnotemap'; -UPDATE branches SET parentNoteId = 'bulkAction' WHERE parentNoteId = 'bulkaction'; -UPDATE branches SET parentNoteId = 'sqlConsole' WHERE parentNoteId = 'sqlconsole'; - -UPDATE attributes SET noteId = 'globalNoteMap' WHERE noteId = 'globalnotemap'; -UPDATE attributes SET noteId = 'bulkAction' WHERE noteId = 'bulkaction'; -UPDATE attributes SET noteId = 'sqlConsole' WHERE noteId = 'sqlconsole'; - -UPDATE attributes SET value = 'globalNoteMap' WHERE type = 'relation' AND value = 'globalnotemap'; -UPDATE attributes SET value = 'bulkAction' WHERE type = 'relation' AND value = 'bulkaction'; -UPDATE attributes SET value = 'sqlConsole' WHERE type = 'relation' AND value = 'sqlconsole'; - -UPDATE entity_changes SET entityId = 'globalNoteMap' WHERE entityId = 'globalnotemap'; -UPDATE entity_changes SET entityId = 'bulkAction' WHERE entityId = 'bulkaction'; -UPDATE entity_changes SET entityId = 'sqlConsole' WHERE entityId = 'sqlconsole'; diff --git a/db/migrations/0201__move_share_under_hidden.sql b/db/migrations/0201__move_share_under_hidden.sql index 68e9eb747..46c1e9979 100644 --- a/db/migrations/0201__move_share_under_hidden.sql +++ b/db/migrations/0201__move_share_under_hidden.sql @@ -1 +1 @@ -UPDATE branches SET parentNoteId = 'hidden' WHERE branchId = 'share'; +UPDATE branches SET parentNoteId = '_hidden' WHERE branchId = '_share'; diff --git a/db/migrations/0202__move_global_note_map_under_hidden.sql b/db/migrations/0202__move_global_note_map_under_hidden.sql index 69363c527..5c5f42812 100644 --- a/db/migrations/0202__move_global_note_map_under_hidden.sql +++ b/db/migrations/0202__move_global_note_map_under_hidden.sql @@ -1 +1,2 @@ -UPDATE branches SET parentNoteId = 'hidden' WHERE noteId = 'globalNoteMap'; +DELETE FROM branches WHERE noteId = '_globalNoteMap' AND parentNoteId != 'singles'; -- make sure there are no clones which would fail at the next line +UPDATE branches SET parentNoteId = '_hidden' WHERE noteId = '_globalNoteMap'; diff --git a/db/migrations/0206__delete_search_and_sql_console_history.js b/db/migrations/0206__delete_search_and_sql_console_history.js index 1c6568f95..089d3f58d 100644 --- a/db/migrations/0206__delete_search_and_sql_console_history.js +++ b/db/migrations/0206__delete_search_and_sql_console_history.js @@ -10,7 +10,7 @@ module.exports = () => { // deleting just branches because they might be cloned (and therefore saved) also outside of the hidden subtree - const searchRoot = becca.getNote('search'); + const searchRoot = becca.getNote('_search'); for (const searchBranch of searchRoot.getChildBranches()) { const searchNote = searchBranch.getNote(); @@ -20,7 +20,7 @@ module.exports = () => { } } - const sqlConsoleRoot = becca.getNote('sqlConsole'); + const sqlConsoleRoot = becca.getNote('_sqlConsole'); for (const sqlConsoleBranch of sqlConsoleRoot.getChildBranches()) { const sqlConsoleNote = sqlConsoleBranch.getNote(); diff --git a/db/migrations/0207__rename_search_and_sql_console.sql b/db/migrations/0207__rename_search_and_sql_console.sql index 79398fd4c..b751faeda 100644 --- a/db/migrations/0207__rename_search_and_sql_console.sql +++ b/db/migrations/0207__rename_search_and_sql_console.sql @@ -1,2 +1,2 @@ -UPDATE notes SET title = 'SQL Console History' WHERE noteId = 'sqlConsole'; -UPDATE notes SET title = 'Search History' WHERE noteId = 'search'; \ No newline at end of file +UPDATE notes SET title = 'SQL Console History' WHERE noteId = '_sqlConsole'; +UPDATE notes SET title = 'Search History' WHERE noteId = '_search'; \ No newline at end of file diff --git a/db/migrations/0208__remove_archived_from_hidden.js b/db/migrations/0208__remove_archived_from_hidden.js index 52089ee6b..0261ab173 100644 --- a/db/migrations/0208__remove_archived_from_hidden.js +++ b/db/migrations/0208__remove_archived_from_hidden.js @@ -6,7 +6,7 @@ module.exports = () => { cls.init(() => { beccaLoader.load(); - for (const label of becca.getNote('hidden').getLabels('archived')) { + for (const label of becca.getNote('_hidden').getLabels('archived')) { label.markAsDeleted('0208__remove_archived_from_hidden'); } }); diff --git a/package-lock.json b/package-lock.json index b6e2c904e..701daf498 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,6 @@ "requires": true, "packages": { "": { - "name": "trilium", "version": "0.57.5", "hasInstallScript": true, "license": "AGPL-3.0-only", diff --git a/src/becca/entities/branch.js b/src/becca/entities/branch.js index 263298e6c..f97fe0ec3 100644 --- a/src/becca/entities/branch.js +++ b/src/becca/entities/branch.js @@ -129,7 +129,7 @@ class Branch extends AbstractEntity { * @returns {boolean} */ get isWeak() { - return ['share', 'lbBookmarks'].includes(this.parentNoteId); + return ['_share', 'lbBookmarks'].includes(this.parentNoteId); } /** @@ -211,7 +211,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.branchId !== '_hidden') { maxNotePos = childBranch.notePosition; } } diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js index 2652d788a..c6dabba29 100644 --- a/src/becca/entities/note.js +++ b/src/becca/entities/note.js @@ -904,7 +904,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' || note.noteId === '_share') { return; } @@ -1342,7 +1342,7 @@ class Note extends AbstractEntity { } isLaunchBarConfig() { - return this.type === 'launcher' || ['lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(this.noteId); + return this.type === 'launcher' || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(this.noteId); } isOptions() { diff --git a/src/public/app/components/entrypoints.js b/src/public/app/components/entrypoints.js index f82e2d361..b1706f357 100644 --- a/src/public/app/components/entrypoints.js +++ b/src/public/app/components/entrypoints.js @@ -95,7 +95,7 @@ export default class Entrypoints extends Component { logoutCommand() { const $logoutForm = $('
') - .append($(``)); + .append($(``)); $("body").append($logoutForm); $logoutForm.trigger('submit'); diff --git a/src/public/app/components/note_context.js b/src/public/app/components/note_context.js index d5ebbbcf1..b61667132 100644 --- a/src/public/app/components/note_context.js +++ b/src/public/app/components/note_context.js @@ -64,15 +64,15 @@ class NoteContext extends Component { } if (this.hoistedNoteId === 'root' - && this.notePath.startsWith("root/hidden") + && this.notePath.startsWith("root/_hidden") && !this.note.hasLabel("keepCurrentHoisting") ) { // hidden subtree displays only when hoisted so it doesn't make sense to keep root as hoisted note - let hoistedNoteId = 'hidden'; + let hoistedNoteId = '_hidden'; if (this.note.isLaunchBarConfig()) { - hoistedNoteId = 'lbRoot'; + hoistedNoteId = '_lbRoot'; } else if (this.note.isOptions()) { hoistedNoteId = 'options'; } diff --git a/src/public/app/components/root_command_executor.js b/src/public/app/components/root_command_executor.js index c053df4f4..31dc561a6 100644 --- a/src/public/app/components/root_command_executor.js +++ b/src/public/app/components/root_command_executor.js @@ -73,19 +73,19 @@ export default class RootCommandExecutor extends Component { } async showBackendLogCommand() { - await appContext.tabManager.openContextWithNote('backendLog', true); + await appContext.tabManager.openContextWithNote('_backendLog', true); } async showLaunchBarSubtreeCommand() { - await this.showAndHoistSubtree('lbRoot'); + await this.showAndHoistSubtree('_lbRoot'); } async showShareSubtreeCommand() { - await this.showAndHoistSubtree('share'); + await this.showAndHoistSubtree('_share'); } async showHiddenSubtreeCommand() { - await this.showAndHoistSubtree('hidden'); + await this.showAndHoistSubtree('_hidden'); } async showOptionsCommand() { @@ -93,11 +93,11 @@ export default class RootCommandExecutor extends Component { } async showSQLConsoleHistoryCommand() { - await this.showAndHoistSubtree('sqlConsole'); + await this.showAndHoistSubtree('_sqlConsole'); } async showSearchHistoryCommand() { - await this.showAndHoistSubtree('search'); + await this.showAndHoistSubtree('_search'); } async showAndHoistSubtree(subtreeNoteId) { diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js index b79aaf778..7cc0f4530 100644 --- a/src/public/app/components/tab_manager.js +++ b/src/public/app/components/tab_manager.js @@ -271,7 +271,7 @@ export default class TabManager extends Component { if (noteContext) { const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId); - if (resolvedNotePath.includes(noteContext.hoistedNoteId) || resolvedNotePath.includes("hidden")) { + if (resolvedNotePath.includes(noteContext.hoistedNoteId) || resolvedNotePath.includes('_hidden')) { hoistedNoteId = noteContext.hoistedNoteId; } } diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js index 3128d744e..dcd026edb 100644 --- a/src/public/app/entities/note_short.js +++ b/src/public/app/entities/note_short.js @@ -344,7 +344,7 @@ class NoteShort { isInHoistedSubTree: path.includes(hoistedNotePath), isArchived: path.find(noteId => froca.notes[noteId].hasLabel('archived')), isSearch: path.find(noteId => froca.notes[noteId].type === 'search'), - isHidden: path.includes("hidden") + isHidden: path.includes('_hidden') })); notePaths.sort((a, b) => { @@ -426,7 +426,7 @@ class NoteShort { else if (this.noteId === 'root') { return "bx bx-chevrons-right"; } - if (this.noteId === 'share') { + if (this.noteId === '_share') { return "bx bx-share-alt"; } else if (this.type === 'text') { @@ -832,7 +832,7 @@ class NoteShort { continue; } - if (parentNote.noteId === 'share' || parentNote.isShared()) { + if (parentNote.noteId === '_share' || parentNote.isShared()) { return true; } } @@ -845,7 +845,7 @@ class NoteShort { } isLaunchBarConfig() { - return this.type === 'launcher' || ['lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(this.noteId); + return this.type === 'launcher' || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(this.noteId); } isOptions() { diff --git a/src/public/app/menus/launcher_context_menu.js b/src/public/app/menus/launcher_context_menu.js index 14d4f023f..00b2f17e8 100644 --- a/src/public/app/menus/launcher_context_menu.js +++ b/src/public/app/menus/launcher_context_menu.js @@ -27,10 +27,10 @@ export default class LauncherContextMenu { const note = await froca.getNote(this.node.data.noteId); const parentNoteId = this.node.getParent().data.noteId; - const isVisibleRoot = note.noteId === 'lbVisibleLaunchers'; - const isAvailableRoot = note.noteId === 'lbAvailableLaunchers'; - const isVisibleItem = parentNoteId === 'lbVisibleLaunchers'; - const isAvailableItem = parentNoteId === 'lbAvailableLaunchers'; + const isVisibleRoot = note.noteId === '_lbVisibleLaunchers'; + const isAvailableRoot = note.noteId === '_lbAvailableLaunchers'; + const isVisibleItem = parentNoteId === '_lbVisibleLaunchers'; + const isAvailableItem = parentNoteId === '_lbAvailableLaunchers'; const isItem = isVisibleItem || isAvailableItem; const canBeDeleted = !note.isLaunchBarConfig(); const canBeReset = note.isLaunchBarConfig(); diff --git a/src/public/app/services/branches.js b/src/public/app/services/branches.js index b45be2e63..c45fff90d 100644 --- a/src/public/app/services/branches.js +++ b/src/public/app/services/branches.js @@ -10,7 +10,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) { branchIdsToMove = filterRootNote(branchIdsToMove); branchIdsToMove = filterSearchBranches(branchIdsToMove); - if (['root', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(beforeBranchId)) { + if (['root', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(beforeBranchId)) { toastService.showError('Cannot move notes here.'); return; } @@ -34,9 +34,9 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) { const forbiddenNoteIds = [ 'root', hoistedNoteService.getHoistedNoteId(), - 'lbRoot', - 'lbAvailableLaunchers', - 'lbVisibleLaunchers' + '_lbRoot', + '_lbAvailableLaunchers', + '_lbVisibleLaunchers' ]; if (forbiddenNoteIds.includes(afterNote.noteId)) { @@ -57,7 +57,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) { } async function moveToParentNote(branchIdsToMove, newParentBranchId) { - if (newParentBranchId === 'lbRoot') { + if (newParentBranchId === '_lbRoot') { toastService.showError('Cannot move notes here.'); return; } diff --git a/src/public/app/services/hoisted_note.js b/src/public/app/services/hoisted_note.js index 11682de7c..0e9b99b5c 100644 --- a/src/public/app/services/hoisted_note.js +++ b/src/public/app/services/hoisted_note.js @@ -50,7 +50,7 @@ async function checkNoteAccess(notePath, noteContext) { const hoistedNoteId = noteContext.hoistedNoteId; - if (!resolvedNotePath.includes(hoistedNoteId) && !resolvedNotePath.includes("hidden")) { + if (!resolvedNotePath.includes(hoistedNoteId) && !resolvedNotePath.includes('_hidden')) { if (!await dialogService.confirm("Requested note is outside of hoisted note subtree and you must unhoist to access the note. Do you want to proceed with unhoisting?")) { return false; } diff --git a/src/public/app/services/keyboard_actions.js b/src/public/app/services/keyboard_actions.js index 4a733c069..d4f88db6e 100644 --- a/src/public/app/services/keyboard_actions.js +++ b/src/public/app/services/keyboard_actions.js @@ -51,10 +51,10 @@ async function getAction(actionName, silent = false) { if (!action) { if (silent) { - console.log(`Cannot find action ${actionName}`); + console.debug(`Cannot find action '${actionName}'`); } else { - throw new Error(`Cannot find action ${actionName}`); + throw new Error(`Cannot find action '${actionName}'`); } } diff --git a/src/public/app/services/note_list_renderer.js b/src/public/app/services/note_list_renderer.js index 2f36b191f..f0d9eb9f7 100644 --- a/src/public/app/services/note_list_renderer.js +++ b/src/public/app/services/note_list_renderer.js @@ -156,7 +156,7 @@ class NoteListRenderer { this.parentNote = parentNote; const includedNoteIds = this.getIncludedNoteIds(); - this.noteIds = noteIds.filter(noteId => !includedNoteIds.has(noteId) && noteId !== 'hidden'); + this.noteIds = noteIds.filter(noteId => !includedNoteIds.has(noteId) && noteId !== '_hidden'); if (this.noteIds.length === 0) { return; diff --git a/src/public/app/services/tree.js b/src/public/app/services/tree.js index ba7c5593a..b6ee91755 100644 --- a/src/public/app/services/tree.js +++ b/src/public/app/services/tree.js @@ -323,7 +323,7 @@ function parseNotePath(notePath) { } function isNotePathInHiddenSubtree(notePath) { - return notePath?.includes("root/hidden"); + return notePath?.includes("root/_hidden"); } export default { diff --git a/src/public/app/widgets/bookmark_buttons.js b/src/public/app/widgets/bookmark_buttons.js index 31585ad5f..0517933c9 100644 --- a/src/public/app/widgets/bookmark_buttons.js +++ b/src/public/app/widgets/bookmark_buttons.js @@ -15,7 +15,7 @@ export default class BookmarkButtons extends FlexContainer { this.children = []; this.noteIds = []; - const bookmarkParentNote = await froca.getNote('lbBookmarks'); + const bookmarkParentNote = await froca.getNote('_lbBookmarks'); for (const note of await bookmarkParentNote.getChildNotes()) { this.noteIds.push(note.noteId); diff --git a/src/public/app/widgets/bookmark_switch.js b/src/public/app/widgets/bookmark_switch.js index 6f6f2a007..5d1a3b3b3 100644 --- a/src/public/app/widgets/bookmark_switch.js +++ b/src/public/app/widgets/bookmark_switch.js @@ -6,7 +6,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget { isEnabled() { return super.isEnabled() // it's not possible to bookmark root because that would clone it under bookmarks and thus create a cycle - && !['root', 'hidden'].includes(this.noteId); + && !['root', '_hidden'].includes(this.noteId); } doRender() { diff --git a/src/public/app/widgets/containers/launcher_container.js b/src/public/app/widgets/containers/launcher_container.js index 78f049d6c..6c7dd21dd 100644 --- a/src/public/app/widgets/containers/launcher_container.js +++ b/src/public/app/widgets/containers/launcher_container.js @@ -19,7 +19,7 @@ export default class LauncherContainer extends FlexContainer { this.children = []; - const visibleLaunchersRoot = await froca.getNote('lbVisibleLaunchers', true); + const visibleLaunchersRoot = await froca.getNote('_lbVisibleLaunchers', true); if (!visibleLaunchersRoot) { console.log("Visible launchers root note doesn't exist."); diff --git a/src/public/app/widgets/dialogs/bulk_actions.js b/src/public/app/widgets/dialogs/bulk_actions.js index 60315ae02..fedd34e01 100644 --- a/src/public/app/widgets/dialogs/bulk_actions.js +++ b/src/public/app/widgets/dialogs/bulk_actions.js @@ -83,7 +83,7 @@ export default class BulkActionsDialog extends BasicWidget { this.$widget.on('click', '[data-action-add]', async event => { const actionName = $(event.target).attr('data-action-add'); - await bulkActionService.addAction('bulkAction', actionName); + await bulkActionService.addAction('_bulkAction', actionName); await this.refresh(); }); @@ -111,7 +111,7 @@ export default class BulkActionsDialog extends BasicWidget { this.$affectedNoteCount.text(affectedNoteCount); - const bulkActionNote = await froca.getNote('bulkAction'); + const bulkActionNote = await froca.getNote('_bulkAction'); const actions = bulkActionService.parseActions(bulkActionNote); @@ -150,7 +150,7 @@ export default class BulkActionsDialog extends BasicWidget { if (loadResults.getAttributes().find(attr => attr.type === 'label' && attr.name === 'action' - && attr.noteId === 'bulkAction' + && attr.noteId === '_bulkAction' && attr.isDeleted)) { // this may be triggered from e.g. sync without open widget, then no need to refresh the widget diff --git a/src/public/app/widgets/floating_buttons/code_buttons.js b/src/public/app/widgets/floating_buttons/code_buttons.js index 0f15e12bf..9363856a5 100644 --- a/src/public/app/widgets/floating_buttons/code_buttons.js +++ b/src/public/app/widgets/floating_buttons/code_buttons.js @@ -76,7 +76,7 @@ export default class CodeButtonsWidget extends NoteContextAwareWidget { this.$saveToNoteButton.toggle( note.mime === 'text/x-sqlite;schema=trilium' - && !note.getAllNotePaths().find(notePathArr => !notePathArr.includes("hidden")) + && !note.getAllNotePaths().find(notePathArr => !notePathArr.includes('_hidden')) ); this.$openTriliumApiDocsButton.toggle(note.mime.startsWith('application/javascript;env=')); diff --git a/src/public/app/widgets/icon_list.js b/src/public/app/widgets/icon_list.js index 4836d0626..1ad713b10 100644 --- a/src/public/app/widgets/icon_list.js +++ b/src/public/app/widgets/icon_list.js @@ -5171,7 +5171,7 @@ const icons = [ "type_of_icon": "REGULAR" }, { - "name": "share", + "name": '_share', "slug": "share-regular", "category_id": 101, "type_of_icon": "REGULAR" @@ -6826,7 +6826,7 @@ const icons = [ "type_of_icon": "SOLID" }, { - "name": "share", + "name": '_share', "slug": "share-solid", "category_id": 101, "type_of_icon": "SOLID" diff --git a/src/public/app/widgets/note_title.js b/src/public/app/widgets/note_title.js index 97b20c759..29ebd1f35 100644 --- a/src/public/app/widgets/note_title.js +++ b/src/public/app/widgets/note_title.js @@ -73,7 +73,7 @@ export default class NoteTitleWidget extends NoteContextAwareWidget { this.$noteTitle.val(note.title); this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) - || ["lbRoot", "lbAvailableLaunchers", "lbVisibleLaunchers"].includes(note.noteId)); + || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(note.noteId)); this.setProtectedStatus(note); } diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 0e2e24e6f..99a2ca523 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -371,7 +371,7 @@ 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'; + return hoistedNoteService.getHoistedNoteId() === '_hidden' || data.node.data.noteId !== '_hidden'; }, activate: async (event, data) => { // click event won't propagate so let's close context menu manually @@ -395,8 +395,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { autoExpandMS: 600, preventLazyParents: false, dragStart: (node, data) => { - if (['root', 'hidden', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(node.data.noteId) - || node.data.noteId.startsWith("options")) { + if (['root', '_hidden', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(node.data.noteId) + || node.data.noteId.startsWith("_options")) { return false; } @@ -424,9 +424,9 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { dragEnter: (node, data) => { if (node.data.noteType === 'search') { return false; - } else if (node.data.noteId === 'lbRoot') { + } else if (node.data.noteId === '_lbRoot') { return false; - } else if (node.data.noteId.startsWith('options')) { + } else if (node.data.noteId.startsWith('_options')) { return false; } else if (node.data.noteType === 'launcher') { return ['before', 'after']; @@ -747,7 +747,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { .map(noteId => froca.notes[noteId]) .filter(note => !!note) .filter(note => - !['share', 'lbBookmarks'].includes(note.noteId) + !['_share', 'lbBookmarks'].includes(note.noteId) && note.type !== 'search'); if (realClones.length > 1) { @@ -1122,7 +1122,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } for (const ecBranch of loadResults.getBranches()) { - if (ecBranch.parentNoteId === 'share') { + if (ecBranch.parentNoteId === '_share') { // all shared notes have a sign in the tree, even the descendants of shared notes noteIdsToReload.add(ecBranch.noteId); } @@ -1335,7 +1335,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } toggleHiddenNode(show) { - const hiddenNode = this.getNodesByNoteId('hidden')[0]; + const hiddenNode = this.getNodesByNoteId('_hidden')[0]; $(hiddenNode.li).toggleClass("hidden-node-is-hidden", !show); } @@ -1568,11 +1568,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { } moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) { - branchService.moveToParentNote(selectedOrActiveBranchIds, 'lbVisibleLaunchers'); + branchService.moveToParentNote(selectedOrActiveBranchIds, '_lbVisibleLaunchers'); } moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) { - branchService.moveToParentNote(selectedOrActiveBranchIds, 'lbAvailableLaunchers'); + branchService.moveToParentNote(selectedOrActiveBranchIds, '_lbAvailableLaunchers'); } addNoteLauncherCommand({node}) { diff --git a/src/public/app/widgets/ribbon_widgets/search_definition.js b/src/public/app/widgets/ribbon_widgets/search_definition.js index a370e1715..0dc4d4841 100644 --- a/src/public/app/widgets/ribbon_widgets/search_definition.js +++ b/src/public/app/widgets/ribbon_widgets/search_definition.js @@ -270,7 +270,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget { async refreshWithNote(note) { this.$component.show(); - this.$saveToNoteButton.toggle(!note.getAllNotePaths().find(notePathArr => !notePathArr.includes("hidden"))); + this.$saveToNoteButton.toggle(!note.getAllNotePaths().find(notePathArr => !notePathArr.includes('_hidden'))); this.$searchOptions.empty(); @@ -295,7 +295,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget { .empty() .append(...actions.map(action => action.render())); - this.$searchAndExecuteButton.css('visibility', actions.length > 0 ? 'visible' : 'hidden'); + this.$searchAndExecuteButton.css('visibility', actions.length > 0 ? 'visible' : '_hidden'); } getContent() { diff --git a/src/public/app/widgets/shared_info.js b/src/public/app/widgets/shared_info.js index 8267bd733..8029ba24b 100644 --- a/src/public/app/widgets/shared_info.js +++ b/src/public/app/widgets/shared_info.js @@ -18,7 +18,7 @@ const TPL = ` export default class SharedInfoWidget extends NoteContextAwareWidget { isEnabled() { - return super.isEnabled() && this.noteId !== 'share' && this.note.hasAncestor('share'); + return super.isEnabled() && this.noteId !== '_share' && this.note.hasAncestor('_share'); } doRender() { @@ -55,7 +55,7 @@ export default class SharedInfoWidget extends NoteContextAwareWidget { } entitiesReloadedEvent({loadResults}) { - if (loadResults.getAttributes().find(attr => attr.name.startsWith("share") && attributeService.isAffecting(attr, this.note))) { + if (loadResults.getAttributes().find(attr => attr.name.startsWith('_share') && attributeService.isAffecting(attr, this.note))) { this.refresh(); } else if (loadResults.getBranches().find(branch => branch.noteId === this.noteId)) { diff --git a/src/public/app/widgets/shared_switch.js b/src/public/app/widgets/shared_switch.js index f159d7023..61dd140db 100644 --- a/src/public/app/widgets/shared_switch.js +++ b/src/public/app/widgets/shared_switch.js @@ -8,7 +8,7 @@ import dialogService from "../services/dialog.js"; export default class SharedSwitchWidget extends SwitchWidget { isEnabled() { return super.isEnabled() - && !['root', 'share', 'hidden'].includes(this.noteId); + && !['root', '_share', '_hidden'].includes(this.noteId); } doRender() { @@ -25,13 +25,13 @@ export default class SharedSwitchWidget extends SwitchWidget { } async switchOn() { - await branchService.cloneNoteToNote(this.noteId, 'share'); + await branchService.cloneNoteToNote(this.noteId, '_share'); syncService.syncNow(true); } async switchOff() { - const shareBranch = this.note.getParentBranches().find(b => b.parentNoteId === 'share'); + const shareBranch = this.note.getParentBranches().find(b => b.parentNoteId === '_share'); if (!shareBranch) { return; @@ -51,8 +51,8 @@ export default class SharedSwitchWidget extends SwitchWidget { } async refreshWithNote(note) { - const isShared = note.hasAncestor('share'); - const canBeUnshared = isShared && note.getParentBranches().find(b => b.parentNoteId === 'share'); + const isShared = note.hasAncestor('_share'); + const canBeUnshared = isShared && note.getParentBranches().find(b => b.parentNoteId === '_share'); const switchDisabled = isShared && !canBeUnshared; this.$switchOn.toggle(!isShared); diff --git a/src/routes/api/bulk_action.js b/src/routes/api/bulk_action.js index ebf431040..78ab1082b 100644 --- a/src/routes/api/bulk_action.js +++ b/src/routes/api/bulk_action.js @@ -6,7 +6,7 @@ function execute(req) { const affectedNoteIds = getAffectedNoteIds(noteIds, includeDescendants); - const bulkActionNote = becca.getNote('bulkAction'); + const bulkActionNote = becca.getNote('_bulkAction'); bulkActionService.executeActions(bulkActionNote, affectedNoteIds); } diff --git a/src/services/anonymization.js b/src/services/anonymization.js index 09fe37739..e7de0ecc8 100644 --- a/src/services/anonymization.js +++ b/src/services/anonymization.js @@ -13,7 +13,7 @@ function getFullAnonymizationScript() { const anonymizeScript = ` UPDATE etapi_tokens SET tokenHash = 'API token hash value'; -UPDATE notes SET title = 'title' WHERE title NOT IN ('root', 'hidden', 'share'); +UPDATE notes SET title = 'title' WHERE title NOT IN ('root', '_hidden', '_share'); UPDATE note_contents SET content = 'text' WHERE content IS NOT NULL; UPDATE note_revisions SET title = 'title'; UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL; diff --git a/src/services/cloning.js b/src/services/cloning.js index bb905f5b6..3fb56473c 100644 --- a/src/services/cloning.js +++ b/src/services/cloning.js @@ -120,9 +120,9 @@ function toggleNoteInParent(present, noteId, parentNoteId, prefix) { } function cloneNoteAfter(noteId, afterBranchId) { - if (['hidden', 'root'].includes(noteId)) { + if (['_hidden', 'root'].includes(noteId)) { return { success: false, message: 'Cloning the given note is forbidden.' }; - } else if (afterBranchId === 'hidden') { + } else if (afterBranchId === '_hidden') { return { success: false, message: 'Cannot clone after the hidden branch.' }; } diff --git a/src/services/export/zip.js b/src/services/export/zip.js index 281a3b2d2..17135c879 100644 --- a/src/services/export/zip.js +++ b/src/services/export/zip.js @@ -152,7 +152,7 @@ function exportToZip(taskContext, branch, format, res) { noteIdToMeta[note.noteId] = meta; const childBranches = note.getChildBranches() - .filter(branch => branch.noteId !== 'hidden'); + .filter(branch => branch.noteId !== '_hidden'); const available = !note.isProtected || protectedSessionService.isProtectedSessionAvailable(); diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.js index 02f75448b..b0c397948 100644 --- a/src/services/hidden_subtree.js +++ b/src/services/hidden_subtree.js @@ -2,18 +2,18 @@ const becca = require("../becca/becca"); const noteService = require("./notes"); const log = require("./log"); -const LBTPL_ROOT = "lbTplRoot"; -const LBTPL_BASE = "lbTplBase"; -const LBTPL_COMMAND = "lbTplCommandLauncher"; -const LBTPL_NOTE_LAUNCHER = "lbTplNoteLauncher"; -const LBTPL_SCRIPT = "lbTplScriptLauncher"; -const LBTPL_BUILTIN_WIDGET = "lbTplBuiltinWidget"; -const LBTPL_SPACER = "lbTplSpacer"; -const LBTPL_CUSTOM_WIDGET = "lbTplCustomWidget"; +const LBTPL_ROOT = "_lbTplRoot"; +const LBTPL_BASE = "_lbTplBase"; +const LBTPL_COMMAND = "_lbTplCommandLauncher"; +const LBTPL_NOTE_LAUNCHER = "_lbTplNoteLauncher"; +const LBTPL_SCRIPT = "_lbTplScriptLauncher"; +const LBTPL_BUILTIN_WIDGET = "_lbTplBuiltinWidget"; +const LBTPL_SPACER = "_lbTplSpacer"; +const LBTPL_CUSTOM_WIDGET = "_lbTplCustomWidget"; const HIDDEN_SUBTREE_DEFINITION = { - id: 'hidden', - title: 'hidden', + id: '_hidden', + title: '_hidden', type: 'doc', icon: 'bx bx-chip', // we want to keep the hidden subtree always last, otherwise there will be problems with e.g. keyboard navigation @@ -24,12 +24,12 @@ const HIDDEN_SUBTREE_DEFINITION = { ], children: [ { - id: 'search', + id: '_search', title: 'Search History', type: 'doc' }, { - id: 'globalNoteMap', + id: '_globalNoteMap', title: 'Note Map', type: 'noteMap', attributes: [ @@ -38,24 +38,24 @@ const HIDDEN_SUBTREE_DEFINITION = { ] }, { - id: 'sqlConsole', + id: '_sqlConsole', title: 'SQL Console History', type: 'doc', icon: 'bx-data' }, { - id: 'share', + id: '_share', title: 'Shared Notes', type: 'doc', - attributes: [ { type: 'label', name: 'docName', value: 'share' } ] + attributes: [ { type: 'label', name: 'docName', value: '_share' } ] }, { - id: 'bulkAction', + id: '_bulkAction', title: 'Bulk action', type: 'doc', }, { - id: 'backendLog', + id: '_backendLog', title: 'Backend Log', type: 'contentWidget', icon: 'bx-terminal', @@ -65,7 +65,7 @@ const HIDDEN_SUBTREE_DEFINITION = { }, { // place for user scripts hidden stuff (scripts should not create notes directly under hidden root) - id: 'userHidden', + id: '_userHidden', title: 'User Hidden', type: 'text', }, @@ -150,7 +150,7 @@ const HIDDEN_SUBTREE_DEFINITION = { ] }, { - id: 'lbRoot', + id: '_lbRoot', title: 'Launch bar', type: 'doc', icon: 'bx-sidebar', @@ -158,65 +158,65 @@ const HIDDEN_SUBTREE_DEFINITION = { attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], children: [ { - id: 'lbAvailableLaunchers', + id: '_lbAvailableLaunchers', title: 'Available Launchers', type: 'doc', icon: 'bx-hide', isExpanded: true, attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], children: [ - { id: 'lbBackInHistory', title: 'Back in History', type: 'launcher', builtinWidget: 'backInHistoryButton', icon: 'bx bxs-left-arrow-square' }, - { id: 'lbForwardInHistory', title: 'Forward in History', type: 'launcher', builtinWidget: 'forwardInHistoryButton', icon: 'bx bxs-right-arrow-square' }, - { id: 'lbBackendLog', title: 'Backend Log', type: 'launcher', targetNoteId: 'backendLog', icon: 'bx bx-terminal' }, + { id: '_lbBackInHistory', title: 'Back in History', type: 'launcher', builtinWidget: 'backInHistoryButton', icon: 'bx bxs-left-arrow-square' }, + { id: '_lbForwardInHistory', title: 'Forward in History', type: 'launcher', builtinWidget: 'forwardInHistoryButton', icon: 'bx bxs-right-arrow-square' }, + { id: '_lbBackendLog', title: 'Backend Log', type: 'launcher', targetNoteId: '_backendLog', icon: 'bx bx-terminal' }, ] }, { - id: 'lbVisibleLaunchers', + id: '_lbVisibleLaunchers', title: 'Visible Launchers', type: 'doc', icon: 'bx-show', isExpanded: true, attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], children: [ - { id: 'lbNewNote', title: 'New Note', type: 'launcher', command: 'createNoteIntoInbox', icon: 'bx bx-file-blank' }, - { id: 'lbSearch', title: 'Search Notes', type: 'launcher', command: 'searchNotes', icon: 'bx bx-search', attributes: [ + { id: '_lbNewNote', title: 'New Note', type: 'launcher', command: 'createNoteIntoInbox', icon: 'bx bx-file-blank' }, + { id: '_lbSearch', title: 'Search Notes', type: 'launcher', command: 'searchNotes', icon: 'bx bx-search', attributes: [ { type: 'label', name: 'desktopOnly' } ] }, - { id: 'lbJumpTo', title: 'Jump to Note', type: 'launcher', command: 'jumpToNote', icon: 'bx bx-send', attributes: [ + { id: '_lbJumpTo', title: 'Jump to Note', type: 'launcher', command: 'jumpToNote', icon: 'bx bx-send', attributes: [ { type: 'label', name: 'desktopOnly' } ] }, - { id: 'lbNoteMap', title: 'Note Map', type: 'launcher', targetNoteId: 'globalNoteMap', icon: 'bx bx-map-alt' }, - { id: 'lbCalendar', title: 'Calendar', type: 'launcher', builtinWidget: 'calendar', icon: 'bx bx-calendar' }, - { id: 'lbRecentChanges', title: 'Recent Changes', type: 'launcher', command: 'showRecentChanges', icon: 'bx bx-history', attributes: [ + { id: '_lbNoteMap', title: 'Note Map', type: 'launcher', targetNoteId: '_globalNoteMap', icon: 'bx bx-map-alt' }, + { id: '_lbCalendar', title: 'Calendar', type: 'launcher', builtinWidget: 'calendar', icon: 'bx bx-calendar' }, + { id: '_lbRecentChanges', title: 'Recent Changes', type: 'launcher', command: 'showRecentChanges', icon: 'bx bx-history', attributes: [ { type: 'label', name: 'desktopOnly' } ] }, - { id: 'lbSpacer1', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "50", growthFactor: "0" }, - { id: 'lbBookmarks', title: 'Bookmarks', type: 'launcher', builtinWidget: 'bookmarks', icon: 'bx bx-bookmark' }, - { id: 'lbToday', title: "Open Today's Journal Note", type: 'launcher', builtinWidget: 'todayInJournal', icon: 'bx bx-calendar-star' }, - { id: 'lbSpacer2', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "0", growthFactor: "1" }, - { id: 'lbProtectedSession', title: 'Protected Session', type: 'launcher', builtinWidget: 'protectedSession', icon: 'bx bx bx-shield-quarter' }, - { id: 'lbSyncStatus', title: 'Sync Status', type: 'launcher', builtinWidget: 'syncStatus', icon: 'bx bx-wifi' } + { id: '_lbSpacer1', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "50", growthFactor: "0" }, + { id: '_lbBookmarks', title: 'Bookmarks', type: 'launcher', builtinWidget: 'bookmarks', icon: 'bx bx-bookmark' }, + { id: '_lbToday', title: "Open Today's Journal Note", type: 'launcher', builtinWidget: 'todayInJournal', icon: 'bx bx-calendar-star' }, + { id: '_lbSpacer2', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "0", growthFactor: "1" }, + { id: '_lbProtectedSession', title: 'Protected Session', type: 'launcher', builtinWidget: 'protectedSession', icon: 'bx bx bx-shield-quarter' }, + { id: '_lbSyncStatus', title: 'Sync Status', type: 'launcher', builtinWidget: 'syncStatus', icon: 'bx bx-wifi' } ] } ] }, { - id: 'options', + id: '_options', title: 'Options', type: 'book', children: [ - { id: 'optionsAppearance', title: 'Appearance', type: 'contentWidget', icon: 'bx-layout' }, - { id: 'optionsShortcuts', title: 'Shortcuts', type: 'contentWidget', icon: 'bxs-keyboard' }, - { id: 'optionsTextNotes', title: 'Text Notes', type: 'contentWidget', icon: 'bx-text' }, - { id: 'optionsCodeNotes', title: 'Code Notes', type: 'contentWidget', icon: 'bx-code' }, - { id: 'optionsImages', title: 'Images', type: 'contentWidget', icon: 'bx-image' }, - { id: 'optionsSpellcheck', title: 'Spellcheck', type: 'contentWidget', icon: 'bx-check-double' }, - { id: 'optionsPassword', title: 'Password', type: 'contentWidget', icon: 'bx-lock' }, - { id: 'optionsEtapi', title: 'ETAPI', type: 'contentWidget', icon: 'bx-extension' }, - { id: 'optionsBackup', title: 'Backup', type: 'contentWidget', icon: 'bx-data' }, - { id: 'optionsSync', title: 'Sync', type: 'contentWidget', icon: 'bx-wifi' }, - { id: 'optionsOther', title: 'Other', type: 'contentWidget', icon: 'bx-dots-horizontal' }, - { id: 'optionsAdvanced', title: 'Advanced', type: 'contentWidget' } + { id: '_optionsAppearance', title: 'Appearance', type: 'contentWidget', icon: 'bx-layout' }, + { id: '_optionsShortcuts', title: 'Shortcuts', type: 'contentWidget', icon: 'bxs-keyboard' }, + { id: '_optionsTextNotes', title: 'Text Notes', type: 'contentWidget', icon: 'bx-text' }, + { id: '_optionsCodeNotes', title: 'Code Notes', type: 'contentWidget', icon: 'bx-code' }, + { id: '_optionsImages', title: 'Images', type: 'contentWidget', icon: 'bx-image' }, + { id: '_optionsSpellcheck', title: 'Spellcheck', type: 'contentWidget', icon: 'bx-check-double' }, + { id: '_optionsPassword', title: 'Password', type: 'contentWidget', icon: 'bx-lock' }, + { id: '_optionsEtapi', title: 'ETAPI', type: 'contentWidget', icon: 'bx-extension' }, + { id: '_optionsBackup', title: 'Backup', type: 'contentWidget', icon: 'bx-data' }, + { id: '_optionsSync', title: 'Sync', type: 'contentWidget', icon: 'bx-wifi' }, + { id: '_optionsOther', title: 'Other', type: 'contentWidget', icon: 'bx-dots-horizontal' }, + { id: '_optionsAdvanced', title: 'Advanced', type: 'contentWidget' } ] } ] @@ -231,9 +231,9 @@ function checkHiddenSubtreeRecursively(parentNoteId, item) { throw new Error(`Item does not contain mandatory properties: ${JSON.stringify(item)}`); } - // if (item.id.charAt(0) !== '_') { - // throw new Error("ID has to start with underscore"); - // } + if (item.id.charAt(0) !== '_') { + throw new Error(`ID has to start with underscore, given '${item.id}'`); + } let note = becca.notes[item.id]; let branch = becca.branches[item.id]; @@ -311,5 +311,13 @@ function checkHiddenSubtreeRecursively(parentNoteId, item) { } module.exports = { - checkHiddenSubtree + checkHiddenSubtree, + LBTPL_ROOT, + LBTPL_BASE, + LBTPL_COMMAND, + LBTPL_NOTE_LAUNCHER, + LBTPL_SCRIPT, + LBTPL_BUILTIN_WIDGET, + LBTPL_SPACER, + LBTPL_CUSTOM_WIDGET }; diff --git a/src/services/hoisted_note.js b/src/services/hoisted_note.js index 0e38b895c..b461ce7ed 100644 --- a/src/services/hoisted_note.js +++ b/src/services/hoisted_note.js @@ -10,7 +10,7 @@ function isHoistedInHiddenSubtree() { if (hoistedNoteId === 'root') { return false; - } else if (hoistedNoteId === 'hidden') { + } else if (hoistedNoteId === '_hidden') { return true; } @@ -20,7 +20,7 @@ function isHoistedInHiddenSubtree() { throw new Error(`Cannot find hoisted note ${hoistedNoteId}`); } - return hoistedNote.hasAncestor('hidden'); + return hoistedNote.hasAncestor('_hidden'); } module.exports = { diff --git a/src/services/notes.js b/src/services/notes.js index 09e1165f9..36ea273dd 100644 --- a/src/services/notes.js +++ b/src/services/notes.js @@ -104,11 +104,11 @@ function getAndValidateParent(params) { throw new ValidationError(`Creating child notes into launcher notes is not allowed.`); } - if (['lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(params.parentNoteId) && params.type !== 'launcher') { + if (['_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(params.parentNoteId) && params.type !== 'launcher') { throw new ValidationError(`Only 'launcher' notes can be created in parent '${params.parentNoteId}'`); } - if (!params.ignoreForbiddenParents && (['lbRoot', 'hidden'].includes(parentNote.noteId) || parentNote.isOptions())) { + if (!params.ignoreForbiddenParents && (['_lbRoot', '_hidden'].includes(parentNote.noteId) || parentNote.isOptions())) { throw new ValidationError(`Creating child notes into '${parentNote.noteId}' is not allowed.`); } diff --git a/src/services/search/services/search.js b/src/services/search/services/search.js index c5038466b..145200e78 100644 --- a/src/services/search/services/search.js +++ b/src/services/search/services/search.js @@ -165,7 +165,7 @@ function findResultsWithExpression(expression, searchContext) { throw new Error(`Can't find note path for note ${JSON.stringify(note.getPojo())}`); } - if (notePathArray.includes("hidden")) { + if (notePathArray.includes('_hidden')) { return null; } diff --git a/src/services/special_notes.js b/src/services/special_notes.js index e7880d816..40d4647eb 100644 --- a/src/services/special_notes.js +++ b/src/services/special_notes.js @@ -6,8 +6,9 @@ const cls = require("./cls"); const dateUtils = require("./date_utils"); const log = require("./log"); const hiddenSubtreeService = require("./hidden_subtree"); -const searchService = require("./search/services/search.js"); -const SearchContext = require("./search/search_context.js"); +const searchService = require("./search/services/search"); +const SearchContext = require("./search/search_context"); +const {LBTPL_NOTE_LAUNCHER, LBTPL_CUSTOM_WIDGET, LBTPL_SPACER, LBTPL_SCRIPT} = require("./hidden_subtree"); function getInboxNote(date) { const hoistedNote = getHoistedNote(); @@ -35,14 +36,14 @@ function getInboxNote(date) { function createSqlConsole() { const {note} = noteService.createNewNote({ - parentNoteId: getMonthlyParentNoteId('sqlConsole'), + parentNoteId: getMonthlyParentNoteId('_sqlConsole'), title: 'SQL Console', content: "SELECT title, isDeleted, isProtected FROM notes WHERE noteId = ''\n\n\n\n", type: 'code', mime: 'text/x-sqlite;schema=trilium' }); - note.setLabel("sqlConsole", dateUtils.localNowDate()); + note.setLabel('_sqlConsole', dateUtils.localNowDate()); note.setLabel('iconClass', 'bx bx-data'); note.setLabel('keepCurrentHoisting'); @@ -60,7 +61,7 @@ function saveSqlConsole(sqlConsoleNoteId) { const result = sqlConsoleNote.cloneTo(sqlConsoleHome.noteId); for (const parentBranch of sqlConsoleNote.getParentBranches()) { - if (parentBranch.parentNote.hasAncestor("hidden")) { + if (parentBranch.parentNote.hasAncestor('_hidden')) { parentBranch.markAsDeleted(); } } @@ -70,7 +71,7 @@ function saveSqlConsole(sqlConsoleNoteId) { function createSearchNote(searchString, ancestorNoteId) { const {note} = noteService.createNewNote({ - parentNoteId: getMonthlyParentNoteId('search'), + parentNoteId: getMonthlyParentNoteId('_search'), title: `Search: ${searchString}`, content: "", type: 'search', @@ -109,7 +110,7 @@ function saveSearchNote(searchNoteId) { const result = searchNote.cloneTo(searchHome.noteId); for (const parentBranch of searchNote.getParentBranches()) { - if (parentBranch.parentNote.hasAncestor("hidden")) { + if (parentBranch.parentNote.hasAncestor('_hidden')) { parentBranch.markAsDeleted(); } } @@ -152,7 +153,7 @@ function createScriptLauncher(parentNoteId, forceNoteId = null) { parentNoteId: parentNoteId }).note; - note.addRelation('template', 'lbTplScriptLauncher'); + note.addRelation('template', LBTPL_SCRIPT); return note; } @@ -167,7 +168,7 @@ function createLauncher(parentNoteId, launcherType) { parentNoteId: parentNoteId }).note; - note.addRelation('template', 'lbTplNoteLauncher'); + note.addRelation('template', LBTPL_NOTE_LAUNCHER); } else if (launcherType === 'script') { note = createScriptLauncher(parentNoteId); } else if (launcherType === 'customWidget') { @@ -178,7 +179,7 @@ function createLauncher(parentNoteId, launcherType) { parentNoteId: parentNoteId }).note; - note.addRelation('template', 'lbTplCustomWidget'); + note.addRelation('template', LBTPL_CUSTOM_WIDGET); } else if (launcherType === 'spacer') { note = noteService.createNewNote({ title: "Spacer", @@ -187,7 +188,7 @@ function createLauncher(parentNoteId, launcherType) { parentNoteId: parentNoteId }).note; - note.addRelation('template', 'lbTplSpacer'); + note.addRelation('template', LBTPL_SPACER); } else { throw new Error(`Unrecognized launcher type '${launcherType}'`); } @@ -203,7 +204,7 @@ function resetLauncher(noteId) { if (note.isLauncherConfig()) { if (note) { - if (noteId === 'lbRoot') { + if (noteId === '_lbRoot') { // deleting hoisted notes are not allowed, so we just reset the children for (const childNote of note.getChildNotes()) { childNote.deleteNote(); @@ -241,7 +242,7 @@ function createOrUpdateScriptLauncherFromApi(opts) { } const launcherNote = becca.getNote(launcherId) - || createScriptLauncher('lbVisibleLaunchers', launcherId); + || createScriptLauncher('_lbVisibleLaunchers', launcherId); launcherNote.title = opts.title; launcherNote.setContent(`(${opts.action})()`); diff --git a/src/services/tree.js b/src/services/tree.js index 13dfd5058..a1665579a 100644 --- a/src/services/tree.js +++ b/src/services/tree.js @@ -30,7 +30,7 @@ function getNotes(noteIds) { } 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.`}; } @@ -187,7 +187,7 @@ function sortNotes(parentNoteId, customSortBy = 'title', reverse = false, folder for (const note of notes) { const branch = note.getParentBranches().find(b => b.parentNoteId === parentNoteId); - if (branch.branchId === 'hidden') { + if (branch.branchId === '_hidden') { position = 999_999_999; } diff --git a/src/share/routes.js b/src/share/routes.js index e53f127a4..626ede63c 100644 --- a/src/share/routes.js +++ b/src/share/routes.js @@ -46,7 +46,7 @@ function checkNoteAccess(noteId, req, res) { return false; } - if (noteId === 'share' && !shaca.shareIndexEnabled) { + if (noteId === '_share' && !shaca.shareIndexEnabled) { res.status(403) .json({ message: `Accessing share index is forbidden.` }); diff --git a/src/share/share_root.js b/src/share/share_root.js index 73dbbab8b..ec63597f2 100644 --- a/src/share/share_root.js +++ b/src/share/share_root.js @@ -1,3 +1,3 @@ module.exports = { - SHARE_ROOT_NOTE_ID: 'share' + SHARE_ROOT_NOTE_ID: '_share' } diff --git a/src/views/share/page.ejs b/src/views/share/page.ejs index abed996c2..1afacd8d1 100644 --- a/src/views/share/page.ejs +++ b/src/views/share/page.ejs @@ -35,7 +35,7 @@
- <% if (note.parents[0].noteId !== 'share' && note.parents.length !== 0) { %> + <% if (note.parents[0].noteId !== '_share' && note.parents.length !== 0) { %>