add prefix "_" to "named" IDs

This commit is contained in:
zadam 2022-12-21 16:11:00 +01:00
parent 1b24276a4a
commit 724f99f17c
49 changed files with 215 additions and 192 deletions

View File

@ -1,6 +1,6 @@
UPDATE etapi_tokens SET tokenHash = 'API token hash value'; 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_contents SET content = 'text' WHERE content IS NOT NULL;
UPDATE note_revisions SET title = 'title'; UPDATE note_revisions SET title = 'title';
UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL; UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL;

View File

@ -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';

View File

@ -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';

View File

@ -1 +1 @@
UPDATE branches SET parentNoteId = 'hidden' WHERE branchId = 'share'; UPDATE branches SET parentNoteId = '_hidden' WHERE branchId = '_share';

View File

@ -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';

View File

@ -10,7 +10,7 @@ module.exports = () => {
// deleting just branches because they might be cloned (and therefore saved) also outside of the hidden subtree // 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()) { for (const searchBranch of searchRoot.getChildBranches()) {
const searchNote = searchBranch.getNote(); 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()) { for (const sqlConsoleBranch of sqlConsoleRoot.getChildBranches()) {
const sqlConsoleNote = sqlConsoleBranch.getNote(); const sqlConsoleNote = sqlConsoleBranch.getNote();

View File

@ -1,2 +1,2 @@
UPDATE notes SET title = 'SQL Console History' WHERE noteId = 'sqlConsole'; UPDATE notes SET title = 'SQL Console History' WHERE noteId = '_sqlConsole';
UPDATE notes SET title = 'Search History' WHERE noteId = 'search'; UPDATE notes SET title = 'Search History' WHERE noteId = '_search';

View File

@ -6,7 +6,7 @@ module.exports = () => {
cls.init(() => { cls.init(() => {
beccaLoader.load(); 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'); label.markAsDeleted('0208__remove_archived_from_hidden');
} }
}); });

1
package-lock.json generated
View File

@ -5,7 +5,6 @@
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "trilium",
"version": "0.57.5", "version": "0.57.5",
"hasInstallScript": true, "hasInstallScript": true,
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",

View File

@ -129,7 +129,7 @@ class Branch extends AbstractEntity {
* @returns {boolean} * @returns {boolean}
*/ */
get isWeak() { 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; let maxNotePos = 0;
for (const childBranch of this.parentNote.getChildBranches()) { for (const childBranch of this.parentNote.getChildBranches()) {
if (maxNotePos < childBranch.notePosition && childBranch.branchId !== 'hidden') { if (maxNotePos < childBranch.notePosition && childBranch.branchId !== '_hidden') {
maxNotePos = childBranch.notePosition; maxNotePos = childBranch.notePosition;
} }
} }

View File

@ -904,7 +904,7 @@ class Note extends AbstractEntity {
function addSubtreeNotesInner(note, parentNote = null) { function addSubtreeNotesInner(note, parentNote = null) {
// share can be removed after 0.57 since it will be put under hidden // 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; return;
} }
@ -1342,7 +1342,7 @@ class Note extends AbstractEntity {
} }
isLaunchBarConfig() { isLaunchBarConfig() {
return this.type === 'launcher' || ['lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(this.noteId); return this.type === 'launcher' || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(this.noteId);
} }
isOptions() { isOptions() {

View File

@ -95,7 +95,7 @@ export default class Entrypoints extends Component {
logoutCommand() { logoutCommand() {
const $logoutForm = $('<form action="logout" method="POST">') const $logoutForm = $('<form action="logout" method="POST">')
.append($(`<input type="hidden" name="_csrf" value="${glob.csrfToken}"/>`)); .append($(`<input type='_hidden' name="_csrf" value="${glob.csrfToken}"/>`));
$("body").append($logoutForm); $("body").append($logoutForm);
$logoutForm.trigger('submit'); $logoutForm.trigger('submit');

View File

@ -64,15 +64,15 @@ class NoteContext extends Component {
} }
if (this.hoistedNoteId === 'root' if (this.hoistedNoteId === 'root'
&& this.notePath.startsWith("root/hidden") && this.notePath.startsWith("root/_hidden")
&& !this.note.hasLabel("keepCurrentHoisting") && !this.note.hasLabel("keepCurrentHoisting")
) { ) {
// hidden subtree displays only when hoisted so it doesn't make sense to keep root as hoisted note // 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()) { if (this.note.isLaunchBarConfig()) {
hoistedNoteId = 'lbRoot'; hoistedNoteId = '_lbRoot';
} else if (this.note.isOptions()) { } else if (this.note.isOptions()) {
hoistedNoteId = 'options'; hoistedNoteId = 'options';
} }

View File

@ -73,19 +73,19 @@ export default class RootCommandExecutor extends Component {
} }
async showBackendLogCommand() { async showBackendLogCommand() {
await appContext.tabManager.openContextWithNote('backendLog', true); await appContext.tabManager.openContextWithNote('_backendLog', true);
} }
async showLaunchBarSubtreeCommand() { async showLaunchBarSubtreeCommand() {
await this.showAndHoistSubtree('lbRoot'); await this.showAndHoistSubtree('_lbRoot');
} }
async showShareSubtreeCommand() { async showShareSubtreeCommand() {
await this.showAndHoistSubtree('share'); await this.showAndHoistSubtree('_share');
} }
async showHiddenSubtreeCommand() { async showHiddenSubtreeCommand() {
await this.showAndHoistSubtree('hidden'); await this.showAndHoistSubtree('_hidden');
} }
async showOptionsCommand() { async showOptionsCommand() {
@ -93,11 +93,11 @@ export default class RootCommandExecutor extends Component {
} }
async showSQLConsoleHistoryCommand() { async showSQLConsoleHistoryCommand() {
await this.showAndHoistSubtree('sqlConsole'); await this.showAndHoistSubtree('_sqlConsole');
} }
async showSearchHistoryCommand() { async showSearchHistoryCommand() {
await this.showAndHoistSubtree('search'); await this.showAndHoistSubtree('_search');
} }
async showAndHoistSubtree(subtreeNoteId) { async showAndHoistSubtree(subtreeNoteId) {

View File

@ -271,7 +271,7 @@ export default class TabManager extends Component {
if (noteContext) { if (noteContext) {
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId); 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; hoistedNoteId = noteContext.hoistedNoteId;
} }
} }

View File

@ -344,7 +344,7 @@ class NoteShort {
isInHoistedSubTree: path.includes(hoistedNotePath), isInHoistedSubTree: path.includes(hoistedNotePath),
isArchived: path.find(noteId => froca.notes[noteId].hasLabel('archived')), isArchived: path.find(noteId => froca.notes[noteId].hasLabel('archived')),
isSearch: path.find(noteId => froca.notes[noteId].type === 'search'), isSearch: path.find(noteId => froca.notes[noteId].type === 'search'),
isHidden: path.includes("hidden") isHidden: path.includes('_hidden')
})); }));
notePaths.sort((a, b) => { notePaths.sort((a, b) => {
@ -426,7 +426,7 @@ class NoteShort {
else if (this.noteId === 'root') { else if (this.noteId === 'root') {
return "bx bx-chevrons-right"; return "bx bx-chevrons-right";
} }
if (this.noteId === 'share') { if (this.noteId === '_share') {
return "bx bx-share-alt"; return "bx bx-share-alt";
} }
else if (this.type === 'text') { else if (this.type === 'text') {
@ -832,7 +832,7 @@ class NoteShort {
continue; continue;
} }
if (parentNote.noteId === 'share' || parentNote.isShared()) { if (parentNote.noteId === '_share' || parentNote.isShared()) {
return true; return true;
} }
} }
@ -845,7 +845,7 @@ class NoteShort {
} }
isLaunchBarConfig() { isLaunchBarConfig() {
return this.type === 'launcher' || ['lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(this.noteId); return this.type === 'launcher' || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(this.noteId);
} }
isOptions() { isOptions() {

View File

@ -27,10 +27,10 @@ export default class LauncherContextMenu {
const note = await froca.getNote(this.node.data.noteId); const note = await froca.getNote(this.node.data.noteId);
const parentNoteId = this.node.getParent().data.noteId; const parentNoteId = this.node.getParent().data.noteId;
const isVisibleRoot = note.noteId === 'lbVisibleLaunchers'; const isVisibleRoot = note.noteId === '_lbVisibleLaunchers';
const isAvailableRoot = note.noteId === 'lbAvailableLaunchers'; const isAvailableRoot = note.noteId === '_lbAvailableLaunchers';
const isVisibleItem = parentNoteId === 'lbVisibleLaunchers'; const isVisibleItem = parentNoteId === '_lbVisibleLaunchers';
const isAvailableItem = parentNoteId === 'lbAvailableLaunchers'; const isAvailableItem = parentNoteId === '_lbAvailableLaunchers';
const isItem = isVisibleItem || isAvailableItem; const isItem = isVisibleItem || isAvailableItem;
const canBeDeleted = !note.isLaunchBarConfig(); const canBeDeleted = !note.isLaunchBarConfig();
const canBeReset = note.isLaunchBarConfig(); const canBeReset = note.isLaunchBarConfig();

View File

@ -10,7 +10,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
branchIdsToMove = filterRootNote(branchIdsToMove); branchIdsToMove = filterRootNote(branchIdsToMove);
branchIdsToMove = filterSearchBranches(branchIdsToMove); branchIdsToMove = filterSearchBranches(branchIdsToMove);
if (['root', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(beforeBranchId)) { if (['root', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(beforeBranchId)) {
toastService.showError('Cannot move notes here.'); toastService.showError('Cannot move notes here.');
return; return;
} }
@ -34,9 +34,9 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
const forbiddenNoteIds = [ const forbiddenNoteIds = [
'root', 'root',
hoistedNoteService.getHoistedNoteId(), hoistedNoteService.getHoistedNoteId(),
'lbRoot', '_lbRoot',
'lbAvailableLaunchers', '_lbAvailableLaunchers',
'lbVisibleLaunchers' '_lbVisibleLaunchers'
]; ];
if (forbiddenNoteIds.includes(afterNote.noteId)) { if (forbiddenNoteIds.includes(afterNote.noteId)) {
@ -57,7 +57,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
} }
async function moveToParentNote(branchIdsToMove, newParentBranchId) { async function moveToParentNote(branchIdsToMove, newParentBranchId) {
if (newParentBranchId === 'lbRoot') { if (newParentBranchId === '_lbRoot') {
toastService.showError('Cannot move notes here.'); toastService.showError('Cannot move notes here.');
return; return;
} }

View File

@ -50,7 +50,7 @@ async function checkNoteAccess(notePath, noteContext) {
const hoistedNoteId = noteContext.hoistedNoteId; 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?")) { 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; return false;
} }

View File

@ -51,10 +51,10 @@ async function getAction(actionName, silent = false) {
if (!action) { if (!action) {
if (silent) { if (silent) {
console.log(`Cannot find action ${actionName}`); console.debug(`Cannot find action '${actionName}'`);
} }
else { else {
throw new Error(`Cannot find action ${actionName}`); throw new Error(`Cannot find action '${actionName}'`);
} }
} }

View File

@ -156,7 +156,7 @@ class NoteListRenderer {
this.parentNote = parentNote; this.parentNote = parentNote;
const includedNoteIds = this.getIncludedNoteIds(); 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) { if (this.noteIds.length === 0) {
return; return;

View File

@ -323,7 +323,7 @@ function parseNotePath(notePath) {
} }
function isNotePathInHiddenSubtree(notePath) { function isNotePathInHiddenSubtree(notePath) {
return notePath?.includes("root/hidden"); return notePath?.includes("root/_hidden");
} }
export default { export default {

View File

@ -15,7 +15,7 @@ export default class BookmarkButtons extends FlexContainer {
this.children = []; this.children = [];
this.noteIds = []; this.noteIds = [];
const bookmarkParentNote = await froca.getNote('lbBookmarks'); const bookmarkParentNote = await froca.getNote('_lbBookmarks');
for (const note of await bookmarkParentNote.getChildNotes()) { for (const note of await bookmarkParentNote.getChildNotes()) {
this.noteIds.push(note.noteId); this.noteIds.push(note.noteId);

View File

@ -6,7 +6,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget {
isEnabled() { isEnabled() {
return super.isEnabled() return super.isEnabled()
// it's not possible to bookmark root because that would clone it under bookmarks and thus create a cycle // 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() { doRender() {

View File

@ -19,7 +19,7 @@ export default class LauncherContainer extends FlexContainer {
this.children = []; this.children = [];
const visibleLaunchersRoot = await froca.getNote('lbVisibleLaunchers', true); const visibleLaunchersRoot = await froca.getNote('_lbVisibleLaunchers', true);
if (!visibleLaunchersRoot) { if (!visibleLaunchersRoot) {
console.log("Visible launchers root note doesn't exist."); console.log("Visible launchers root note doesn't exist.");

View File

@ -83,7 +83,7 @@ export default class BulkActionsDialog extends BasicWidget {
this.$widget.on('click', '[data-action-add]', async event => { this.$widget.on('click', '[data-action-add]', async event => {
const actionName = $(event.target).attr('data-action-add'); const actionName = $(event.target).attr('data-action-add');
await bulkActionService.addAction('bulkAction', actionName); await bulkActionService.addAction('_bulkAction', actionName);
await this.refresh(); await this.refresh();
}); });
@ -111,7 +111,7 @@ export default class BulkActionsDialog extends BasicWidget {
this.$affectedNoteCount.text(affectedNoteCount); this.$affectedNoteCount.text(affectedNoteCount);
const bulkActionNote = await froca.getNote('bulkAction'); const bulkActionNote = await froca.getNote('_bulkAction');
const actions = bulkActionService.parseActions(bulkActionNote); const actions = bulkActionService.parseActions(bulkActionNote);
@ -150,7 +150,7 @@ export default class BulkActionsDialog extends BasicWidget {
if (loadResults.getAttributes().find(attr => if (loadResults.getAttributes().find(attr =>
attr.type === 'label' attr.type === 'label'
&& attr.name === 'action' && attr.name === 'action'
&& attr.noteId === 'bulkAction' && attr.noteId === '_bulkAction'
&& attr.isDeleted)) { && attr.isDeleted)) {
// this may be triggered from e.g. sync without open widget, then no need to refresh the widget // this may be triggered from e.g. sync without open widget, then no need to refresh the widget

View File

@ -76,7 +76,7 @@ export default class CodeButtonsWidget extends NoteContextAwareWidget {
this.$saveToNoteButton.toggle( this.$saveToNoteButton.toggle(
note.mime === 'text/x-sqlite;schema=trilium' 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=')); this.$openTriliumApiDocsButton.toggle(note.mime.startsWith('application/javascript;env='));

View File

@ -5171,7 +5171,7 @@ const icons = [
"type_of_icon": "REGULAR" "type_of_icon": "REGULAR"
}, },
{ {
"name": "share", "name": '_share',
"slug": "share-regular", "slug": "share-regular",
"category_id": 101, "category_id": 101,
"type_of_icon": "REGULAR" "type_of_icon": "REGULAR"
@ -6826,7 +6826,7 @@ const icons = [
"type_of_icon": "SOLID" "type_of_icon": "SOLID"
}, },
{ {
"name": "share", "name": '_share',
"slug": "share-solid", "slug": "share-solid",
"category_id": 101, "category_id": 101,
"type_of_icon": "SOLID" "type_of_icon": "SOLID"

View File

@ -73,7 +73,7 @@ export default class NoteTitleWidget extends NoteContextAwareWidget {
this.$noteTitle.val(note.title); this.$noteTitle.val(note.title);
this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) this.$noteTitle.prop("readonly", (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable())
|| ["lbRoot", "lbAvailableLaunchers", "lbVisibleLaunchers"].includes(note.noteId)); || ['_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(note.noteId));
this.setProtectedStatus(note); this.setProtectedStatus(note);
} }

View File

@ -371,7 +371,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}, },
beforeActivate: (event, data) => { beforeActivate: (event, data) => {
// hidden subtree is hidden hackily, prevent activating it e.g. by keyboard // 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) => { activate: async (event, data) => {
// click event won't propagate so let's close context menu manually // click event won't propagate so let's close context menu manually
@ -395,8 +395,8 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
autoExpandMS: 600, autoExpandMS: 600,
preventLazyParents: false, preventLazyParents: false,
dragStart: (node, data) => { dragStart: (node, data) => {
if (['root', 'hidden', 'lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(node.data.noteId) if (['root', '_hidden', '_lbRoot', '_lbAvailableLaunchers', '_lbVisibleLaunchers'].includes(node.data.noteId)
|| node.data.noteId.startsWith("options")) { || node.data.noteId.startsWith("_options")) {
return false; return false;
} }
@ -424,9 +424,9 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
dragEnter: (node, data) => { dragEnter: (node, data) => {
if (node.data.noteType === 'search') { if (node.data.noteType === 'search') {
return false; return false;
} else if (node.data.noteId === 'lbRoot') { } else if (node.data.noteId === '_lbRoot') {
return false; return false;
} else if (node.data.noteId.startsWith('options')) { } else if (node.data.noteId.startsWith('_options')) {
return false; return false;
} else if (node.data.noteType === 'launcher') { } else if (node.data.noteType === 'launcher') {
return ['before', 'after']; return ['before', 'after'];
@ -747,7 +747,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
.map(noteId => froca.notes[noteId]) .map(noteId => froca.notes[noteId])
.filter(note => !!note) .filter(note => !!note)
.filter(note => .filter(note =>
!['share', 'lbBookmarks'].includes(note.noteId) !['_share', 'lbBookmarks'].includes(note.noteId)
&& note.type !== 'search'); && note.type !== 'search');
if (realClones.length > 1) { if (realClones.length > 1) {
@ -1122,7 +1122,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
} }
for (const ecBranch of loadResults.getBranches()) { 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 // all shared notes have a sign in the tree, even the descendants of shared notes
noteIdsToReload.add(ecBranch.noteId); noteIdsToReload.add(ecBranch.noteId);
} }
@ -1335,7 +1335,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
} }
toggleHiddenNode(show) { toggleHiddenNode(show) {
const hiddenNode = this.getNodesByNoteId('hidden')[0]; const hiddenNode = this.getNodesByNoteId('_hidden')[0];
$(hiddenNode.li).toggleClass("hidden-node-is-hidden", !show); $(hiddenNode.li).toggleClass("hidden-node-is-hidden", !show);
} }
@ -1568,11 +1568,11 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
} }
moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) { moveShortcutToVisibleCommand({node, selectedOrActiveBranchIds}) {
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lbVisibleLaunchers'); branchService.moveToParentNote(selectedOrActiveBranchIds, '_lbVisibleLaunchers');
} }
moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) { moveShortcutToAvailableCommand({node, selectedOrActiveBranchIds}) {
branchService.moveToParentNote(selectedOrActiveBranchIds, 'lbAvailableLaunchers'); branchService.moveToParentNote(selectedOrActiveBranchIds, '_lbAvailableLaunchers');
} }
addNoteLauncherCommand({node}) { addNoteLauncherCommand({node}) {

View File

@ -270,7 +270,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
async refreshWithNote(note) { async refreshWithNote(note) {
this.$component.show(); 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(); this.$searchOptions.empty();
@ -295,7 +295,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
.empty() .empty()
.append(...actions.map(action => action.render())); .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() { getContent() {

View File

@ -18,7 +18,7 @@ const TPL = `
export default class SharedInfoWidget extends NoteContextAwareWidget { export default class SharedInfoWidget extends NoteContextAwareWidget {
isEnabled() { isEnabled() {
return super.isEnabled() && this.noteId !== 'share' && this.note.hasAncestor('share'); return super.isEnabled() && this.noteId !== '_share' && this.note.hasAncestor('_share');
} }
doRender() { doRender() {
@ -55,7 +55,7 @@ export default class SharedInfoWidget extends NoteContextAwareWidget {
} }
entitiesReloadedEvent({loadResults}) { 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(); this.refresh();
} }
else if (loadResults.getBranches().find(branch => branch.noteId === this.noteId)) { else if (loadResults.getBranches().find(branch => branch.noteId === this.noteId)) {

View File

@ -8,7 +8,7 @@ import dialogService from "../services/dialog.js";
export default class SharedSwitchWidget extends SwitchWidget { export default class SharedSwitchWidget extends SwitchWidget {
isEnabled() { isEnabled() {
return super.isEnabled() return super.isEnabled()
&& !['root', 'share', 'hidden'].includes(this.noteId); && !['root', '_share', '_hidden'].includes(this.noteId);
} }
doRender() { doRender() {
@ -25,13 +25,13 @@ export default class SharedSwitchWidget extends SwitchWidget {
} }
async switchOn() { async switchOn() {
await branchService.cloneNoteToNote(this.noteId, 'share'); await branchService.cloneNoteToNote(this.noteId, '_share');
syncService.syncNow(true); syncService.syncNow(true);
} }
async switchOff() { async switchOff() {
const shareBranch = this.note.getParentBranches().find(b => b.parentNoteId === 'share'); const shareBranch = this.note.getParentBranches().find(b => b.parentNoteId === '_share');
if (!shareBranch) { if (!shareBranch) {
return; return;
@ -51,8 +51,8 @@ export default class SharedSwitchWidget extends SwitchWidget {
} }
async refreshWithNote(note) { async refreshWithNote(note) {
const isShared = note.hasAncestor('share'); const isShared = note.hasAncestor('_share');
const canBeUnshared = isShared && note.getParentBranches().find(b => b.parentNoteId === 'share'); const canBeUnshared = isShared && note.getParentBranches().find(b => b.parentNoteId === '_share');
const switchDisabled = isShared && !canBeUnshared; const switchDisabled = isShared && !canBeUnshared;
this.$switchOn.toggle(!isShared); this.$switchOn.toggle(!isShared);

View File

@ -6,7 +6,7 @@ function execute(req) {
const affectedNoteIds = getAffectedNoteIds(noteIds, includeDescendants); const affectedNoteIds = getAffectedNoteIds(noteIds, includeDescendants);
const bulkActionNote = becca.getNote('bulkAction'); const bulkActionNote = becca.getNote('_bulkAction');
bulkActionService.executeActions(bulkActionNote, affectedNoteIds); bulkActionService.executeActions(bulkActionNote, affectedNoteIds);
} }

View File

@ -13,7 +13,7 @@ function getFullAnonymizationScript() {
const anonymizeScript = ` const anonymizeScript = `
UPDATE etapi_tokens SET tokenHash = 'API token hash value'; 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_contents SET content = 'text' WHERE content IS NOT NULL;
UPDATE note_revisions SET title = 'title'; UPDATE note_revisions SET title = 'title';
UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL; UPDATE note_revision_contents SET content = 'text' WHERE content IS NOT NULL;

View File

@ -120,9 +120,9 @@ function toggleNoteInParent(present, noteId, parentNoteId, prefix) {
} }
function cloneNoteAfter(noteId, afterBranchId) { function cloneNoteAfter(noteId, afterBranchId) {
if (['hidden', 'root'].includes(noteId)) { if (['_hidden', 'root'].includes(noteId)) {
return { success: false, message: 'Cloning the given note is forbidden.' }; 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.' }; return { success: false, message: 'Cannot clone after the hidden branch.' };
} }

View File

@ -152,7 +152,7 @@ function exportToZip(taskContext, branch, format, res) {
noteIdToMeta[note.noteId] = meta; noteIdToMeta[note.noteId] = meta;
const childBranches = note.getChildBranches() const childBranches = note.getChildBranches()
.filter(branch => branch.noteId !== 'hidden'); .filter(branch => branch.noteId !== '_hidden');
const available = !note.isProtected || protectedSessionService.isProtectedSessionAvailable(); const available = !note.isProtected || protectedSessionService.isProtectedSessionAvailable();

View File

@ -2,18 +2,18 @@ const becca = require("../becca/becca");
const noteService = require("./notes"); const noteService = require("./notes");
const log = require("./log"); const log = require("./log");
const LBTPL_ROOT = "lbTplRoot"; const LBTPL_ROOT = "_lbTplRoot";
const LBTPL_BASE = "lbTplBase"; const LBTPL_BASE = "_lbTplBase";
const LBTPL_COMMAND = "lbTplCommandLauncher"; const LBTPL_COMMAND = "_lbTplCommandLauncher";
const LBTPL_NOTE_LAUNCHER = "lbTplNoteLauncher"; const LBTPL_NOTE_LAUNCHER = "_lbTplNoteLauncher";
const LBTPL_SCRIPT = "lbTplScriptLauncher"; const LBTPL_SCRIPT = "_lbTplScriptLauncher";
const LBTPL_BUILTIN_WIDGET = "lbTplBuiltinWidget"; const LBTPL_BUILTIN_WIDGET = "_lbTplBuiltinWidget";
const LBTPL_SPACER = "lbTplSpacer"; const LBTPL_SPACER = "_lbTplSpacer";
const LBTPL_CUSTOM_WIDGET = "lbTplCustomWidget"; const LBTPL_CUSTOM_WIDGET = "_lbTplCustomWidget";
const HIDDEN_SUBTREE_DEFINITION = { const HIDDEN_SUBTREE_DEFINITION = {
id: 'hidden', id: '_hidden',
title: 'hidden', title: '_hidden',
type: 'doc', type: 'doc',
icon: 'bx bx-chip', icon: 'bx bx-chip',
// we want to keep the hidden subtree always last, otherwise there will be problems with e.g. keyboard navigation // 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: [ children: [
{ {
id: 'search', id: '_search',
title: 'Search History', title: 'Search History',
type: 'doc' type: 'doc'
}, },
{ {
id: 'globalNoteMap', id: '_globalNoteMap',
title: 'Note Map', title: 'Note Map',
type: 'noteMap', type: 'noteMap',
attributes: [ attributes: [
@ -38,24 +38,24 @@ const HIDDEN_SUBTREE_DEFINITION = {
] ]
}, },
{ {
id: 'sqlConsole', id: '_sqlConsole',
title: 'SQL Console History', title: 'SQL Console History',
type: 'doc', type: 'doc',
icon: 'bx-data' icon: 'bx-data'
}, },
{ {
id: 'share', id: '_share',
title: 'Shared Notes', title: 'Shared Notes',
type: 'doc', type: 'doc',
attributes: [ { type: 'label', name: 'docName', value: 'share' } ] attributes: [ { type: 'label', name: 'docName', value: '_share' } ]
}, },
{ {
id: 'bulkAction', id: '_bulkAction',
title: 'Bulk action', title: 'Bulk action',
type: 'doc', type: 'doc',
}, },
{ {
id: 'backendLog', id: '_backendLog',
title: 'Backend Log', title: 'Backend Log',
type: 'contentWidget', type: 'contentWidget',
icon: 'bx-terminal', 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) // place for user scripts hidden stuff (scripts should not create notes directly under hidden root)
id: 'userHidden', id: '_userHidden',
title: 'User Hidden', title: 'User Hidden',
type: 'text', type: 'text',
}, },
@ -150,7 +150,7 @@ const HIDDEN_SUBTREE_DEFINITION = {
] ]
}, },
{ {
id: 'lbRoot', id: '_lbRoot',
title: 'Launch bar', title: 'Launch bar',
type: 'doc', type: 'doc',
icon: 'bx-sidebar', icon: 'bx-sidebar',
@ -158,65 +158,65 @@ const HIDDEN_SUBTREE_DEFINITION = {
attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ],
children: [ children: [
{ {
id: 'lbAvailableLaunchers', id: '_lbAvailableLaunchers',
title: 'Available Launchers', title: 'Available Launchers',
type: 'doc', type: 'doc',
icon: 'bx-hide', icon: 'bx-hide',
isExpanded: true, isExpanded: true,
attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ],
children: [ children: [
{ id: 'lbBackInHistory', title: 'Back in History', type: 'launcher', builtinWidget: 'backInHistoryButton', icon: 'bx bxs-left-arrow-square' }, { 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: '_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: '_lbBackendLog', title: 'Backend Log', type: 'launcher', targetNoteId: '_backendLog', icon: 'bx bx-terminal' },
] ]
}, },
{ {
id: 'lbVisibleLaunchers', id: '_lbVisibleLaunchers',
title: 'Visible Launchers', title: 'Visible Launchers',
type: 'doc', type: 'doc',
icon: 'bx-show', icon: 'bx-show',
isExpanded: true, isExpanded: true,
attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ], attributes: [ { type: 'label', name: 'docName', value: 'launchbar_intro' } ],
children: [ children: [
{ id: 'lbNewNote', title: 'New Note', type: 'launcher', command: 'createNoteIntoInbox', icon: 'bx bx-file-blank' }, { 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: '_lbSearch', title: 'Search Notes', type: 'launcher', command: 'searchNotes', icon: 'bx bx-search', attributes: [
{ type: 'label', name: 'desktopOnly' } { 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' } { type: 'label', name: 'desktopOnly' }
] }, ] },
{ id: 'lbNoteMap', title: 'Note Map', type: 'launcher', targetNoteId: 'globalNoteMap', icon: 'bx bx-map-alt' }, { 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: '_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: '_lbRecentChanges', title: 'Recent Changes', type: 'launcher', command: 'showRecentChanges', icon: 'bx bx-history', attributes: [
{ type: 'label', name: 'desktopOnly' } { type: 'label', name: 'desktopOnly' }
] }, ] },
{ id: 'lbSpacer1', title: 'Spacer', type: 'launcher', builtinWidget: 'spacer', baseSize: "50", growthFactor: "0" }, { 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: '_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: '_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: '_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: '_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: '_lbSyncStatus', title: 'Sync Status', type: 'launcher', builtinWidget: 'syncStatus', icon: 'bx bx-wifi' }
] ]
} }
] ]
}, },
{ {
id: 'options', id: '_options',
title: 'Options', title: 'Options',
type: 'book', type: 'book',
children: [ children: [
{ id: 'optionsAppearance', title: 'Appearance', type: 'contentWidget', icon: 'bx-layout' }, { id: '_optionsAppearance', title: 'Appearance', type: 'contentWidget', icon: 'bx-layout' },
{ id: 'optionsShortcuts', title: 'Shortcuts', type: 'contentWidget', icon: 'bxs-keyboard' }, { id: '_optionsShortcuts', title: 'Shortcuts', type: 'contentWidget', icon: 'bxs-keyboard' },
{ id: 'optionsTextNotes', title: 'Text Notes', type: 'contentWidget', icon: 'bx-text' }, { id: '_optionsTextNotes', title: 'Text Notes', type: 'contentWidget', icon: 'bx-text' },
{ id: 'optionsCodeNotes', title: 'Code Notes', type: 'contentWidget', icon: 'bx-code' }, { id: '_optionsCodeNotes', title: 'Code Notes', type: 'contentWidget', icon: 'bx-code' },
{ id: 'optionsImages', title: 'Images', type: 'contentWidget', icon: 'bx-image' }, { id: '_optionsImages', title: 'Images', type: 'contentWidget', icon: 'bx-image' },
{ id: 'optionsSpellcheck', title: 'Spellcheck', type: 'contentWidget', icon: 'bx-check-double' }, { id: '_optionsSpellcheck', title: 'Spellcheck', type: 'contentWidget', icon: 'bx-check-double' },
{ id: 'optionsPassword', title: 'Password', type: 'contentWidget', icon: 'bx-lock' }, { id: '_optionsPassword', title: 'Password', type: 'contentWidget', icon: 'bx-lock' },
{ id: 'optionsEtapi', title: 'ETAPI', type: 'contentWidget', icon: 'bx-extension' }, { id: '_optionsEtapi', title: 'ETAPI', type: 'contentWidget', icon: 'bx-extension' },
{ id: 'optionsBackup', title: 'Backup', type: 'contentWidget', icon: 'bx-data' }, { id: '_optionsBackup', title: 'Backup', type: 'contentWidget', icon: 'bx-data' },
{ id: 'optionsSync', title: 'Sync', type: 'contentWidget', icon: 'bx-wifi' }, { id: '_optionsSync', title: 'Sync', type: 'contentWidget', icon: 'bx-wifi' },
{ id: 'optionsOther', title: 'Other', type: 'contentWidget', icon: 'bx-dots-horizontal' }, { id: '_optionsOther', title: 'Other', type: 'contentWidget', icon: 'bx-dots-horizontal' },
{ id: 'optionsAdvanced', title: 'Advanced', type: 'contentWidget' } { 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)}`); throw new Error(`Item does not contain mandatory properties: ${JSON.stringify(item)}`);
} }
// if (item.id.charAt(0) !== '_') { if (item.id.charAt(0) !== '_') {
// throw new Error("ID has to start with underscore"); throw new Error(`ID has to start with underscore, given '${item.id}'`);
// } }
let note = becca.notes[item.id]; let note = becca.notes[item.id];
let branch = becca.branches[item.id]; let branch = becca.branches[item.id];
@ -311,5 +311,13 @@ function checkHiddenSubtreeRecursively(parentNoteId, item) {
} }
module.exports = { module.exports = {
checkHiddenSubtree checkHiddenSubtree,
LBTPL_ROOT,
LBTPL_BASE,
LBTPL_COMMAND,
LBTPL_NOTE_LAUNCHER,
LBTPL_SCRIPT,
LBTPL_BUILTIN_WIDGET,
LBTPL_SPACER,
LBTPL_CUSTOM_WIDGET
}; };

View File

@ -10,7 +10,7 @@ function isHoistedInHiddenSubtree() {
if (hoistedNoteId === 'root') { if (hoistedNoteId === 'root') {
return false; return false;
} else if (hoistedNoteId === 'hidden') { } else if (hoistedNoteId === '_hidden') {
return true; return true;
} }
@ -20,7 +20,7 @@ function isHoistedInHiddenSubtree() {
throw new Error(`Cannot find hoisted note ${hoistedNoteId}`); throw new Error(`Cannot find hoisted note ${hoistedNoteId}`);
} }
return hoistedNote.hasAncestor('hidden'); return hoistedNote.hasAncestor('_hidden');
} }
module.exports = { module.exports = {

View File

@ -104,11 +104,11 @@ function getAndValidateParent(params) {
throw new ValidationError(`Creating child notes into launcher notes is not allowed.`); 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}'`); 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.`); throw new ValidationError(`Creating child notes into '${parentNote.noteId}' is not allowed.`);
} }

View File

@ -165,7 +165,7 @@ function findResultsWithExpression(expression, searchContext) {
throw new Error(`Can't find note path for note ${JSON.stringify(note.getPojo())}`); throw new Error(`Can't find note path for note ${JSON.stringify(note.getPojo())}`);
} }
if (notePathArray.includes("hidden")) { if (notePathArray.includes('_hidden')) {
return null; return null;
} }

View File

@ -6,8 +6,9 @@ const cls = require("./cls");
const dateUtils = require("./date_utils"); const dateUtils = require("./date_utils");
const log = require("./log"); const log = require("./log");
const hiddenSubtreeService = require("./hidden_subtree"); const hiddenSubtreeService = require("./hidden_subtree");
const searchService = require("./search/services/search.js"); const searchService = require("./search/services/search");
const SearchContext = require("./search/search_context.js"); const SearchContext = require("./search/search_context");
const {LBTPL_NOTE_LAUNCHER, LBTPL_CUSTOM_WIDGET, LBTPL_SPACER, LBTPL_SCRIPT} = require("./hidden_subtree");
function getInboxNote(date) { function getInboxNote(date) {
const hoistedNote = getHoistedNote(); const hoistedNote = getHoistedNote();
@ -35,14 +36,14 @@ function getInboxNote(date) {
function createSqlConsole() { function createSqlConsole() {
const {note} = noteService.createNewNote({ const {note} = noteService.createNewNote({
parentNoteId: getMonthlyParentNoteId('sqlConsole'), parentNoteId: getMonthlyParentNoteId('_sqlConsole'),
title: 'SQL Console', title: 'SQL Console',
content: "SELECT title, isDeleted, isProtected FROM notes WHERE noteId = ''\n\n\n\n", content: "SELECT title, isDeleted, isProtected FROM notes WHERE noteId = ''\n\n\n\n",
type: 'code', type: 'code',
mime: 'text/x-sqlite;schema=trilium' mime: 'text/x-sqlite;schema=trilium'
}); });
note.setLabel("sqlConsole", dateUtils.localNowDate()); note.setLabel('_sqlConsole', dateUtils.localNowDate());
note.setLabel('iconClass', 'bx bx-data'); note.setLabel('iconClass', 'bx bx-data');
note.setLabel('keepCurrentHoisting'); note.setLabel('keepCurrentHoisting');
@ -60,7 +61,7 @@ function saveSqlConsole(sqlConsoleNoteId) {
const result = sqlConsoleNote.cloneTo(sqlConsoleHome.noteId); const result = sqlConsoleNote.cloneTo(sqlConsoleHome.noteId);
for (const parentBranch of sqlConsoleNote.getParentBranches()) { for (const parentBranch of sqlConsoleNote.getParentBranches()) {
if (parentBranch.parentNote.hasAncestor("hidden")) { if (parentBranch.parentNote.hasAncestor('_hidden')) {
parentBranch.markAsDeleted(); parentBranch.markAsDeleted();
} }
} }
@ -70,7 +71,7 @@ function saveSqlConsole(sqlConsoleNoteId) {
function createSearchNote(searchString, ancestorNoteId) { function createSearchNote(searchString, ancestorNoteId) {
const {note} = noteService.createNewNote({ const {note} = noteService.createNewNote({
parentNoteId: getMonthlyParentNoteId('search'), parentNoteId: getMonthlyParentNoteId('_search'),
title: `Search: ${searchString}`, title: `Search: ${searchString}`,
content: "", content: "",
type: 'search', type: 'search',
@ -109,7 +110,7 @@ function saveSearchNote(searchNoteId) {
const result = searchNote.cloneTo(searchHome.noteId); const result = searchNote.cloneTo(searchHome.noteId);
for (const parentBranch of searchNote.getParentBranches()) { for (const parentBranch of searchNote.getParentBranches()) {
if (parentBranch.parentNote.hasAncestor("hidden")) { if (parentBranch.parentNote.hasAncestor('_hidden')) {
parentBranch.markAsDeleted(); parentBranch.markAsDeleted();
} }
} }
@ -152,7 +153,7 @@ function createScriptLauncher(parentNoteId, forceNoteId = null) {
parentNoteId: parentNoteId parentNoteId: parentNoteId
}).note; }).note;
note.addRelation('template', 'lbTplScriptLauncher'); note.addRelation('template', LBTPL_SCRIPT);
return note; return note;
} }
@ -167,7 +168,7 @@ function createLauncher(parentNoteId, launcherType) {
parentNoteId: parentNoteId parentNoteId: parentNoteId
}).note; }).note;
note.addRelation('template', 'lbTplNoteLauncher'); note.addRelation('template', LBTPL_NOTE_LAUNCHER);
} else if (launcherType === 'script') { } else if (launcherType === 'script') {
note = createScriptLauncher(parentNoteId); note = createScriptLauncher(parentNoteId);
} else if (launcherType === 'customWidget') { } else if (launcherType === 'customWidget') {
@ -178,7 +179,7 @@ function createLauncher(parentNoteId, launcherType) {
parentNoteId: parentNoteId parentNoteId: parentNoteId
}).note; }).note;
note.addRelation('template', 'lbTplCustomWidget'); note.addRelation('template', LBTPL_CUSTOM_WIDGET);
} else if (launcherType === 'spacer') { } else if (launcherType === 'spacer') {
note = noteService.createNewNote({ note = noteService.createNewNote({
title: "Spacer", title: "Spacer",
@ -187,7 +188,7 @@ function createLauncher(parentNoteId, launcherType) {
parentNoteId: parentNoteId parentNoteId: parentNoteId
}).note; }).note;
note.addRelation('template', 'lbTplSpacer'); note.addRelation('template', LBTPL_SPACER);
} else { } else {
throw new Error(`Unrecognized launcher type '${launcherType}'`); throw new Error(`Unrecognized launcher type '${launcherType}'`);
} }
@ -203,7 +204,7 @@ function resetLauncher(noteId) {
if (note.isLauncherConfig()) { if (note.isLauncherConfig()) {
if (note) { if (note) {
if (noteId === 'lbRoot') { if (noteId === '_lbRoot') {
// deleting hoisted notes are not allowed, so we just reset the children // deleting hoisted notes are not allowed, so we just reset the children
for (const childNote of note.getChildNotes()) { for (const childNote of note.getChildNotes()) {
childNote.deleteNote(); childNote.deleteNote();
@ -241,7 +242,7 @@ function createOrUpdateScriptLauncherFromApi(opts) {
} }
const launcherNote = becca.getNote(launcherId) const launcherNote = becca.getNote(launcherId)
|| createScriptLauncher('lbVisibleLaunchers', launcherId); || createScriptLauncher('_lbVisibleLaunchers', launcherId);
launcherNote.title = opts.title; launcherNote.title = opts.title;
launcherNote.setContent(`(${opts.action})()`); launcherNote.setContent(`(${opts.action})()`);

View File

@ -30,7 +30,7 @@ function getNotes(noteIds) {
} }
function validateParentChild(parentNoteId, childNoteId, branchId = null) { 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.`}; 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) { for (const note of notes) {
const branch = note.getParentBranches().find(b => b.parentNoteId === parentNoteId); const branch = note.getParentBranches().find(b => b.parentNoteId === parentNoteId);
if (branch.branchId === 'hidden') { if (branch.branchId === '_hidden') {
position = 999_999_999; position = 999_999_999;
} }

View File

@ -46,7 +46,7 @@ function checkNoteAccess(noteId, req, res) {
return false; return false;
} }
if (noteId === 'share' && !shaca.shareIndexEnabled) { if (noteId === '_share' && !shaca.shareIndexEnabled) {
res.status(403) res.status(403)
.json({ message: `Accessing share index is forbidden.` }); .json({ message: `Accessing share index is forbidden.` });

View File

@ -1,3 +1,3 @@
module.exports = { module.exports = {
SHARE_ROOT_NOTE_ID: 'share' SHARE_ROOT_NOTE_ID: '_share'
} }

View File

@ -35,7 +35,7 @@
<body data-note-id="<%= note.noteId %>"> <body data-note-id="<%= note.noteId %>">
<div id="layout"> <div id="layout">
<div id="main"> <div id="main">
<% if (note.parents[0].noteId !== 'share' && note.parents.length !== 0) { %> <% if (note.parents[0].noteId !== '_share' && note.parents.length !== 0) { %>
<nav id="parentLink"> <nav id="parentLink">
parent: <a href="<%= note.parents[0].shareId %>" parent: <a href="<%= note.parents[0].shareId %>"
class="type-<%= note.parents[0].type %>"><%= note.parents[0].title %></a> class="type-<%= note.parents[0].type %>"><%= note.parents[0].title %></a>

View File

@ -33,12 +33,12 @@ Content-Type: application/json
{ {
"branchId": "forcedClonedId", "branchId": "forcedClonedId",
"noteId": "{{createdNoteId}}", "noteId": "{{createdNoteId}}",
"parentNoteId": "hidden" "parentNoteId": '_hidden'
} }
> {% > {%
client.assert(response.status === 201); client.assert(response.status === 201);
client.assert(response.body.parentNoteId == "hidden"); client.assert(response.body.parentNoteId == '_hidden');
client.global.set("clonedBranchId", response.body.branchId); client.global.set("clonedBranchId", response.body.branchId);
@ -88,7 +88,7 @@ Authorization: {{authToken}}
> {% > {%
client.assert(response.status === 200); client.assert(response.status === 200);
client.assert(response.body.branchId == client.global.get("clonedBranchId")); client.assert(response.body.branchId == client.global.get("clonedBranchId"));
client.assert(response.body.parentNoteId == "hidden"); client.assert(response.body.parentNoteId == '_hidden');
%} %}
### ###

View File

@ -22,7 +22,7 @@ Content-Type: application/json
{ {
"noteId": "{{createdNoteId}}", "noteId": "{{createdNoteId}}",
"parentNoteId": "hidden" "parentNoteId": '_hidden'
} }
> {% client.global.set("clonedBranchId", response.body.branchId); %} > {% client.global.set("clonedBranchId", response.body.branchId); %}

View File

@ -38,7 +38,7 @@ Content-Type: application/json
{ {
"noteId": "{{createdNoteId}}", "noteId": "{{createdNoteId}}",
"parentNoteId": "hidden" "parentNoteId": '_hidden'
} }
> {% client.global.set("clonedBranchId", response.body.branchId); %} > {% client.global.set("clonedBranchId", response.body.branchId); %}