Skip to content

Build your personal knowledge base with Trilium Notes

fixed history navigation buttons

zadame5e0add1a2d6
diff --git a/src/public/app/components/note_context.js b/src/public/app/components/note_context.js
index 60f790b341..4a1e7476b4 100644
--- a/src/public/app/components/note_context.js
+++ b/src/public/app/components/note_context.js
@@ -39,8 +39,6 @@ class NoteContext extends Component {
async setNote(inputNotePath, triggerSwitchEvent = true) {
const resolvedNotePath = await this.getResolvedNotePath(inputNotePath);
- console.log("EEEEEE", inputNotePath, resolvedNotePath);
-
if (!resolvedNotePath) {
return;
}
diff --git a/src/public/app/widgets/buttons/abstract_button.js b/src/public/app/widgets/buttons/abstract_button.js
index 3671063295..13f15a2e37 100644
--- a/src/public/app/widgets/buttons/abstract_button.js
+++ b/src/public/app/widgets/buttons/abstract_button.js
@@ -87,5 +87,6 @@ export default class AbstractButtonWidget extends NoteContextAwareWidget {
onContextMenu(handler) {
this.settings.onContextMenu = handler;
+ return this;
}
}
diff --git a/src/public/app/widgets/buttons/history/history_back.js b/src/public/app/widgets/buttons/history/history_back.js
deleted file mode 100644
index b549599e05..0000000000
--- a/src/public/app/widgets/buttons/history/history_back.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import AbstractHistoryNavigationWidget from "./abstract_history.js";
-
-export default class BackInHistoryButtonWidget extends AbstractHistoryNavigationWidget {
- constructor() {
- super();
-
- this.icon('bx-left-arrow-circle')
- .title("Go to previous note.")
- .command("backInNoteHistory")
- .titlePlacement("right")
- .buttonNoteIdProvider(() => 'lbBackInHistory')
- .onContextMenu(e => this.showContextMenu(e));
- }
-}
diff --git a/src/public/app/widgets/buttons/history/history_forward.js b/src/public/app/widgets/buttons/history/history_forward.js
deleted file mode 100644
index 5c8a3ad62e..0000000000
--- a/src/public/app/widgets/buttons/history/history_forward.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import AbstractHistoryNavigationWidget from "./abstract_history.js";
-
-export default class ForwardInHistoryButtonWidget extends AbstractHistoryNavigationWidget {
- constructor() {
- super();
-
- this.icon('bx-left-arrow-circle')
- .title("Go to next note.")
- .command("forwardInNoteHistory")
- .titlePlacement("right")
- .buttonNoteIdProvider(() => 'lbForwardInHistory')
- .onContextMenu(e => this.showContextMenu(e));
- }
-}
diff --git a/src/public/app/widgets/buttons/history/abstract_history.js b/src/public/app/widgets/buttons/history_navigation.js
similarity index 76%
rename from src/public/app/widgets/buttons/history/abstract_history.js
rename to src/public/app/widgets/buttons/history_navigation.js
index c356961e13..15de9454f9 100644
--- a/src/public/app/widgets/buttons/history/abstract_history.js
+++ b/src/public/app/widgets/buttons/history_navigation.js
@@ -1,9 +1,21 @@
-import utils from "../../../services/utils.js";
-import contextMenu from "../../../menus/context_menu.js";
-import treeService from "../../../services/tree.js";
-import ButtonFromNoteWidget from "../button_from_note.js";
+import utils from "../../services/utils.js";
+import contextMenu from "../../menus/context_menu.js";
+import treeService from "../../services/tree.js";
+import ButtonFromNoteWidget from "./button_from_note.js";
+
+export default class HistoryNavigationButton extends ButtonFromNoteWidget {
+ constructor(launcherNote, command) {
+ super();
+
+ this.title(() => launcherNote.title)
+ .icon(() => launcherNote.getIcon())
+ .command(() => command)
+ .titlePlacement("right")
+ .buttonNoteIdProvider(() => launcherNote.noteId)
+ .onContextMenu(e => this.showContextMenu(e))
+ .class("launcher-button");
+ }
-export default class AbstractHistoryNavigationWidget extends ButtonFromNoteWidget {
isEnabled() {
return super.isEnabled() && utils.isElectron();
}
diff --git a/src/public/app/widgets/containers/launcher.js b/src/public/app/widgets/containers/launcher.js
index 68fcf322c7..b093c60e96 100644
--- a/src/public/app/widgets/containers/launcher.js
+++ b/src/public/app/widgets/containers/launcher.js
@@ -3,14 +3,13 @@ import SpacerWidget from "../spacer.js";
import BookmarkButtons from "../bookmark_buttons.js";
import ProtectedSessionStatusWidget from "../buttons/protected_session_status.js";
import SyncStatusWidget from "../sync_status.js";
-import BackInHistoryButtonWidget from "../buttons/history/history_back.js";
-import ForwardInHistoryButtonWidget from "../buttons/history/history_forward.js";
import BasicWidget from "../basic_widget.js";
import NoteLauncher from "../buttons/launcher/note_launcher.js";
import ScriptLauncher from "../buttons/launcher/script_launcher.js";
import CommandButtonWidget from "../buttons/command_button.js";
import utils from "../../services/utils.js";
import TodayLauncher from "../buttons/launcher/today_launcher.js";
+import HistoryNavigationButton from "../buttons/history_navigation.js";
export default class LauncherWidget extends BasicWidget {
constructor() {
@@ -66,8 +65,8 @@ export default class LauncherWidget extends BasicWidget {
initCommandLauncherWidget(note) {
return new CommandButtonWidget()
- .title(note.title)
- .icon(note.getIcon())
+ .title(() => note.title)
+ .icon(() => note.getIcon())
.command(() => note.getLabelValue("command"));
}
@@ -99,9 +98,9 @@ export default class LauncherWidget extends BasicWidget {
} else if (builtinWidget === 'syncStatus') {
return new SyncStatusWidget();
} else if (builtinWidget === 'backInHistoryButton') {
- return new BackInHistoryButtonWidget();
+ return new HistoryNavigationButton(note, "backInNoteHistory");
} else if (builtinWidget === 'forwardInHistoryButton') {
- return new ForwardInHistoryButtonWidget();
+ return new HistoryNavigationButton(note, "forwardInNoteHistory");
} else if (builtinWidget === 'todayInJournal') {
return new TodayLauncher(note);
} else {
diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.js
index 071f68549d..98606355e9 100644
--- a/src/services/hidden_subtree.js
+++ b/src/services/hidden_subtree.js
@@ -167,8 +167,8 @@ const HIDDEN_SUBTREE_DEFINITION = {
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: '_lbBackInHistory', title: 'Go to Previous Note', type: 'launcher', builtinWidget: 'backInHistoryButton', icon: 'bx bxs-left-arrow-square' },
+ { id: '_lbForwardInHistory', title: 'Go to Next Note', type: 'launcher', builtinWidget: 'forwardInHistoryButton', icon: 'bx bxs-right-arrow-square' },
{ id: '_lbBackendLog', title: 'Backend Log', type: 'launcher', targetNoteId: '_backendLog', icon: 'bx bx-terminal' },
]
},