Skip to content

Build your personal knowledge base with Trilium Notes

launchbar WIP

zadam75654583326d
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8524fae44a..ea0feb5958 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,7 +3,7 @@
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="openjdk-18" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="openjdk-16" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
diff --git a/src/public/app/layouts/desktop_layout.js b/src/public/app/layouts/desktop_layout.js
index d36e159824..5cab44cf4f 100644
--- a/src/public/app/layouts/desktop_layout.js
+++ b/src/public/app/layouts/desktop_layout.js
@@ -78,6 +78,7 @@ import OptionsDialog from "../widgets/dialogs/options.js";
import FloatingButtons from "../widgets/floating_buttons/floating_buttons.js";
import RelationMapButtons from "../widgets/floating_buttons/relation_map_buttons.js";
import MermaidExportButton from "../widgets/floating_buttons/mermaid_export_button.js";
+import ShortcutContainer from "../widgets/containers/shortcut_container.js";
export default class DesktopLayout {
constructor(customWidgets) {
@@ -93,33 +94,34 @@ export default class DesktopLayout {
.id("launcher-pane")
.css("width", "53px")
.child(new GlobalMenuWidget())
- .child(new ButtonWidget()
- .icon("bx-file-blank")
- .title("New note")
- .command("createNoteIntoInbox"))
- .child(new ButtonWidget()
- .icon("bx-search")
- .title("Search")
- .command("searchNotes"))
- .child(new ButtonWidget()
- .icon("bx-send")
- .title("Jump to note")
- .command("jumpToNote"))
- .child(new OpenNoteButtonWidget()
- .targetNote('globalnotemap'))
- .child(new ButtonWidget()
- .icon("bx-history")
- .title("Show recent changes")
- .command("showRecentChanges"))
- .child(new CalendarWidget())
- .child(new SpacerWidget(40, 0))
- .child(new FlexContainer("column")
- .id("plugin-buttons")
- .contentSized())
- .child(new BookmarkButtons())
- .child(new SpacerWidget(0, 1000))
- .child(new ProtectedSessionStatusWidget())
- .child(new SyncStatusWidget())
+ .child(new ShortcutContainer())
+ // .child(new ButtonWidget()
+ // .icon("bx-file-blank")
+ // .title("New note")
+ // .command("createNoteIntoInbox"))
+ // .child(new ButtonWidget()
+ // .icon("bx-search")
+ // .title("Search")
+ // .command("searchNotes"))
+ // .child(new ButtonWidget()
+ // .icon("bx-send")
+ // .title("Jump to note")
+ // .command("jumpToNote"))
+ // .child(new OpenNoteButtonWidget()
+ // .targetNote('globalnotemap'))
+ // .child(new ButtonWidget()
+ // .icon("bx-history")
+ // .title("Show recent changes")
+ // .command("showRecentChanges"))
+ // .child(new CalendarWidget())
+ // .child(new SpacerWidget(40, 0))
+ // .child(new FlexContainer("column")
+ // .id("plugin-buttons")
+ // .contentSized())
+ // .child(new BookmarkButtons())
+ // .child(new SpacerWidget(0, 1000))
+ // .child(new ProtectedSessionStatusWidget())
+ // .child(new SyncStatusWidget())
.child(new LeftPaneToggleWidget())
)
.child(new LeftPaneContainer()
diff --git a/src/public/app/services/root_command_executor.js b/src/public/app/services/root_command_executor.js
index f87f5e7b25..e781e2c292 100644
--- a/src/public/app/services/root_command_executor.js
+++ b/src/public/app/services/root_command_executor.js
@@ -70,4 +70,8 @@ export default class RootCommandExecutor extends Component {
toggleLeftPaneCommand() {
options.toggle('leftPaneVisible');
}
+
+ showLaunchBarShortcutsCommand() {
+ appContext.tabManager.openContextWithNote('lb_root', true, null, 'lb_root');
+ }
}
diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.js
index efc0c03966..d071b8a78f 100644
--- a/src/public/app/widgets/buttons/global_menu.js
+++ b/src/public/app/widgets/buttons/global_menu.js
@@ -47,6 +47,11 @@ const TPL = `
</button>
<div class="dropdown-menu dropdown-menu-right">
+ <a class="dropdown-item options-button" data-trigger-command="showLaunchBarShortcuts">
+ <span class="bx bx-slider"></span>
+ Show launchbar shortcuts
+ </a>
+
<a class="dropdown-item options-button" data-trigger-command="showOptions">
<span class="bx bx-slider"></span>
Options
diff --git a/src/public/app/widgets/containers/container.js b/src/public/app/widgets/containers/container.js
index 7703e2eae3..a298ab95e1 100644
--- a/src/public/app/widgets/containers/container.js
+++ b/src/public/app/widgets/containers/container.js
@@ -30,7 +30,10 @@ export default class Container extends BasicWidget {
doRender() {
this.$widget = $(`<div>`);
+ this.renderChildren();
+ }
+ renderChildren() {
for (const widget of this.children) {
this.$widget.append(widget.render());
}
diff --git a/src/public/app/widgets/containers/left_pane_container.js b/src/public/app/widgets/containers/left_pane_container.js
index b04363f08a..5c6c065509 100644
--- a/src/public/app/widgets/containers/left_pane_container.js
+++ b/src/public/app/widgets/containers/left_pane_container.js
@@ -11,7 +11,7 @@ export default class LeftPaneContainer extends FlexContainer {
}
isEnabled() {
- return super.isEnabled() && options.is( 'leftPaneVisible');
+ return super.isEnabled() && options.is('leftPaneVisible');
}
entitiesReloadedEvent({loadResults}) {
diff --git a/src/public/app/widgets/containers/shortcut_container.js b/src/public/app/widgets/containers/shortcut_container.js
new file mode 100644
index 0000000000..923686a124
--- /dev/null
+++ b/src/public/app/widgets/containers/shortcut_container.js
@@ -0,0 +1,42 @@
+import FlexContainer from "./flex_container.js";
+import froca from "../../services/froca.js";
+import ButtonWidget from "../buttons/button_widget.js";
+
+export default class ShortcutContainer extends FlexContainer {
+ constructor() {
+ super('column');
+
+ this.id('shortcut-container');
+ this.css('height', '100%');
+ this.filling();
+
+ this.load();
+ }
+
+ async load() {
+ this.children = [];
+
+ const visibleShortcutsRoot = await froca.getNote('lb_visibleshortcuts');
+
+ console.log(await visibleShortcutsRoot.getChildNotes());
+
+ for (const shortcut of await visibleShortcutsRoot.getChildNotes()) {
+ this.child(new ButtonWidget()
+ .icon(shortcut.getLabelValue("iconClass"))
+ .title(shortcut.title)
+ .command(shortcut.getLabelValue("command")));
+ }
+
+ this.$widget.empty();
+ this.renderChildren();
+
+ this.handleEventInChildren('initialRenderComplete');
+ }
+
+ entitiesReloadedEvent({loadResults}) {
+ if (loadResults.getNotes().find(note => note.noteId.startsWith("lb_"))
+ || loadResults.getBranches().find(branch => branch.branchId.startsWith("lb_"))) {
+ this.load();
+ }
+ }
+}
diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js
index 9224d67d4c..137e6a8f7d 100644
--- a/src/public/app/widgets/note_tree.js
+++ b/src/public/app/widgets/note_tree.js
@@ -601,10 +601,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
for (const branch of childBranches) {
- if (branch.noteId === 'hidden') {
- continue;
- }
-
if (hideArchivedNotes) {
const note = branch.getNoteFromCache();
@@ -936,7 +932,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
if (this.noteContext
&& this.noteContext.notePath
&& !this.noteContext.note.isDeleted
- && !this.noteContext.notePath.includes("root/hidden")
) {
const newActiveNode = await this.getNodeFromPath(this.noteContext.notePath);
@@ -1083,7 +1078,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
}
}
- if (!ecBranch.isDeleted && ecBranch.noteId !== 'hidden') {
+ if (!ecBranch.isDeleted) {
for (const parentNode of this.getNodesByNoteId(ecBranch.parentNoteId)) {
if (parentNode.isFolder() && !parentNode.isLoaded()) {
continue;
diff --git a/src/services/special_notes.js b/src/services/special_notes.js
index 88ce3f8a9a..7321c25fde 100644
--- a/src/services/special_notes.js
+++ b/src/services/special_notes.js
@@ -237,12 +237,12 @@ function getBulkActionNote() {
}
function getLaunchBarRoot() {
- let note = becca.getNote('launchbar');
+ let note = becca.getNote('lb_root');
if (!note) {
note = noteService.createNewNote({
- branchId: 'launchbar',
- noteId: 'launchbar',
+ branchId: 'lb_root',
+ noteId: 'lb_root',
title: 'Launch bar',
type: 'text',
content: '',
@@ -288,13 +288,11 @@ function getLaunchBarVisibleShortcutsRoot() {
}
const shortcuts = [
- { id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank' },
- { id: 'lb_searcj', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search' },
- { id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send' },
- { id: 'lb_notemap', targetNote: 'globalnotemap', title: 'Note map', icon: 'bx bx-map' },
- { id: 'lb_recentchanges', command: 'showRecentChanges', title: 'Show recent changes', icon: 'bx bx-history' },
- { id: 'lb_recentchanges', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send' },
-
+ { id: 'lb_newnote', command: 'createNoteIntoInbox', title: 'New note', icon: 'bx bx-file-blank', isVisible: true },
+ { id: 'lb_search', command: 'searchNotes', title: 'Search notes', icon: 'bx bx-search', isVisible: true },
+ { id: 'lb_jumpto', command: 'jumpToNote', title: 'Jump to note', icon: 'bx bx-send', isVisible: true },
+ { id: 'lb_notemap', targetNote: 'globalnotemap', title: 'Note map', icon: 'bx bx-map-alt', isVisible: true },
+ { id: 'lb_recentchanges', command: 'showRecentChanges', title: 'Show recent changes', icon: 'bx bx-history', isVisible: false }
];
function createMissingSpecialNotes() {
@@ -304,7 +302,27 @@ function createMissingSpecialNotes() {
getBulkActionNote();
getLaunchBarRoot();
getLaunchBarAvailableShortcutsRoot();
- getLaunchBarVisibleShortcutsRoot();
+ getLaunchBarVisibleShortcutsRoot()
+
+ for (const shortcut of shortcuts) {
+ let note = becca.getNote(shortcut.id);
+ const parentNoteId = shortcut.isVisible ? getLaunchBarVisibleShortcutsRoot().noteId : getLaunchBarAvailableShortcutsRoot().noteId;
+
+ if (!note) {
+ note = noteService.createNewNote({
+ branchId: shortcut.id,
+ noteId: shortcut.id,
+ title: shortcut.title,
+ type: 'text',
+ content: '',
+ parentNoteId: parentNoteId
+ }).note;
+
+ note.addLabel('builtinShortcut');
+ note.addLabel('iconClass', shortcut.icon);
+ note.addLabel('command', shortcut.command);
+ }
+ }
// share root is not automatically created since it's visible in the tree and many won't need it/use it