mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	fixed history navigation buttons
This commit is contained in:
		@@ -39,8 +39,6 @@ class NoteContext extends Component {
 | 
				
			|||||||
    async setNote(inputNotePath, triggerSwitchEvent = true) {
 | 
					    async setNote(inputNotePath, triggerSwitchEvent = true) {
 | 
				
			||||||
        const resolvedNotePath = await this.getResolvedNotePath(inputNotePath);
 | 
					        const resolvedNotePath = await this.getResolvedNotePath(inputNotePath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        console.log("EEEEEE", inputNotePath, resolvedNotePath);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (!resolvedNotePath) {
 | 
					        if (!resolvedNotePath) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -87,5 +87,6 @@ export default class AbstractButtonWidget extends NoteContextAwareWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    onContextMenu(handler) {
 | 
					    onContextMenu(handler) {
 | 
				
			||||||
        this.settings.onContextMenu = handler;
 | 
					        this.settings.onContextMenu = handler;
 | 
				
			||||||
 | 
					        return this;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -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));
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,9 +1,21 @@
 | 
				
			|||||||
import utils from "../../../services/utils.js";
 | 
					import utils from "../../services/utils.js";
 | 
				
			||||||
import contextMenu from "../../../menus/context_menu.js";
 | 
					import contextMenu from "../../menus/context_menu.js";
 | 
				
			||||||
import treeService from "../../../services/tree.js";
 | 
					import treeService from "../../services/tree.js";
 | 
				
			||||||
import ButtonFromNoteWidget from "../button_from_note.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() {
 | 
					    isEnabled() {
 | 
				
			||||||
        return super.isEnabled() && utils.isElectron();
 | 
					        return super.isEnabled() && utils.isElectron();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@@ -3,14 +3,13 @@ import SpacerWidget from "../spacer.js";
 | 
				
			|||||||
import BookmarkButtons from "../bookmark_buttons.js";
 | 
					import BookmarkButtons from "../bookmark_buttons.js";
 | 
				
			||||||
import ProtectedSessionStatusWidget from "../buttons/protected_session_status.js";
 | 
					import ProtectedSessionStatusWidget from "../buttons/protected_session_status.js";
 | 
				
			||||||
import SyncStatusWidget from "../sync_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 BasicWidget from "../basic_widget.js";
 | 
				
			||||||
import NoteLauncher from "../buttons/launcher/note_launcher.js";
 | 
					import NoteLauncher from "../buttons/launcher/note_launcher.js";
 | 
				
			||||||
import ScriptLauncher from "../buttons/launcher/script_launcher.js";
 | 
					import ScriptLauncher from "../buttons/launcher/script_launcher.js";
 | 
				
			||||||
import CommandButtonWidget from "../buttons/command_button.js";
 | 
					import CommandButtonWidget from "../buttons/command_button.js";
 | 
				
			||||||
import utils from "../../services/utils.js";
 | 
					import utils from "../../services/utils.js";
 | 
				
			||||||
import TodayLauncher from "../buttons/launcher/today_launcher.js";
 | 
					import TodayLauncher from "../buttons/launcher/today_launcher.js";
 | 
				
			||||||
 | 
					import HistoryNavigationButton from "../buttons/history_navigation.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class LauncherWidget extends BasicWidget {
 | 
					export default class LauncherWidget extends BasicWidget {
 | 
				
			||||||
    constructor() {
 | 
					    constructor() {
 | 
				
			||||||
@@ -66,8 +65,8 @@ export default class LauncherWidget extends BasicWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    initCommandLauncherWidget(note) {
 | 
					    initCommandLauncherWidget(note) {
 | 
				
			||||||
        return new CommandButtonWidget()
 | 
					        return new CommandButtonWidget()
 | 
				
			||||||
            .title(note.title)
 | 
					            .title(() => note.title)
 | 
				
			||||||
            .icon(note.getIcon())
 | 
					            .icon(() => note.getIcon())
 | 
				
			||||||
            .command(() => note.getLabelValue("command"));
 | 
					            .command(() => note.getLabelValue("command"));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -99,9 +98,9 @@ export default class LauncherWidget extends BasicWidget {
 | 
				
			|||||||
        } else if (builtinWidget === 'syncStatus') {
 | 
					        } else if (builtinWidget === 'syncStatus') {
 | 
				
			||||||
            return new SyncStatusWidget();
 | 
					            return new SyncStatusWidget();
 | 
				
			||||||
        } else if (builtinWidget === 'backInHistoryButton') {
 | 
					        } else if (builtinWidget === 'backInHistoryButton') {
 | 
				
			||||||
            return new BackInHistoryButtonWidget();
 | 
					            return new HistoryNavigationButton(note, "backInNoteHistory");
 | 
				
			||||||
        } else if (builtinWidget === 'forwardInHistoryButton') {
 | 
					        } else if (builtinWidget === 'forwardInHistoryButton') {
 | 
				
			||||||
            return new ForwardInHistoryButtonWidget();
 | 
					            return new HistoryNavigationButton(note, "forwardInNoteHistory");
 | 
				
			||||||
        } else if (builtinWidget === 'todayInJournal') {
 | 
					        } else if (builtinWidget === 'todayInJournal') {
 | 
				
			||||||
            return new TodayLauncher(note);
 | 
					            return new TodayLauncher(note);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -167,8 +167,8 @@ const HIDDEN_SUBTREE_DEFINITION = {
 | 
				
			|||||||
                    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: 'Go to Previous Note', 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: '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' },
 | 
					                        { id: '_lbBackendLog', title: 'Backend Log', type: 'launcher', targetNoteId: '_backendLog', icon: 'bx bx-terminal' },
 | 
				
			||||||
                    ]
 | 
					                    ]
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user