@@ -20,6 +23,26 @@ export default class HistoryNavigationWidget extends BasicWidget {
doRender() {
if (utils.isElectron()) {
this.$widget = $(TPL);
+
+ this.$backInHistory = this.$widget.find("[data-trigger-command='backInNoteHistory']");
+ this.$backInHistory.on('contextmenu', e => {
+ e.preventDefault();
+
+ if (this.webContents.history.length < 2) {
+ return;
+ }
+
+ this.showContextMenu(e);
+ });
+
+
+ this.$forwardInHistory = this.$widget.find("[data-trigger-command='forwardInNoteHistory']");
+
+ const electron = require('electron');
+ this.webContents = electron.remote.getCurrentWindow().webContents;
+ this.webContents.clearHistory();
+
+ this.refresh();
}
else {
this.$widget = $("
");
@@ -27,4 +50,50 @@ export default class HistoryNavigationWidget extends BasicWidget {
return this.$widget;
}
+
+ async showContextMenu(e) {
+ let items = [];
+
+ for (const url of this.webContents.history) {
+ const [_, notePathWithTab] = url.split('#');
+ const [notePath, tabId] = notePathWithTab.split('-');
+
+ const title = await treeService.getNotePathTitle(notePath);
+
+ items.push({
+ title,
+ notePath,
+ tabId,
+ uiIcon: "empty"
+ });
+ }
+
+ items.reverse();
+
+ items = items.slice(1); // remove the current note
+
+ if (items.length > 20) {
+ items = items.slice(0, 20);
+ }
+
+ contextMenu.show({
+ x: e.pageX,
+ y: e.pageY,
+ items,
+ selectMenuItemHandler: ({notePath, tabId}) => appContext.tabManager.switchToTab(tabId, notePath)
+ });
+ }
+
+ refresh() {
+ if (!utils.isElectron()) {
+ return;
+ }
+
+ this.$backInHistory.toggleClass('disabled', !this.webContents.canGoBack());
+ this.$forwardInHistory.toggleClass('disabled', !this.webContents.canGoForward());
+ }
+
+ activeNoteChangedEvent() {
+ this.refresh();
+ }
}
\ No newline at end of file
diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css
index b96a4d2f1..920463de5 100644
--- a/src/public/stylesheets/style.css
+++ b/src/public/stylesheets/style.css
@@ -185,7 +185,7 @@ span.fancytree-node.archived {
overflow-x: hidden;
}
-.icon-action:hover {
+.icon-action:hover:not(.disabled) {
text-decoration: none;
border-color: var(--button-border-color);
}
@@ -198,6 +198,11 @@ span.fancytree-node.archived {
font-size: 1.5em;
}
+.icon-action.disabled {
+ color: var(--muted-text-color) !important;
+ cursor: not-allowed;
+}
+
.ui-widget-content a:not(.ui-tabs-anchor) {
color: #337ab7 !important;
}