fix keyboard shortcut for "open externally"

This commit is contained in:
zadam 2021-04-24 22:18:25 +02:00
parent ccac46527c
commit b9133cb683
4 changed files with 16 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import treeCache from "./tree_cache.js";
import bundleService from "./bundle.js";
import DialogCommandExecutor from "./dialog_command_executor.js";
import RootCommandExecutor from "./root_command_executor.js";
import Entrypoints from "./entrypoints.js";
import options from "./options.js";
import utils from "./utils.js";
@ -57,7 +57,7 @@ class AppContext extends Component {
this.executors = [
this.tabManager,
new DialogCommandExecutor(),
new RootCommandExecutor(),
new Entrypoints(),
new MainTreeExecutors()
];

View File

@ -2,8 +2,9 @@ import Component from "../widgets/component.js";
import appContext from "./app_context.js";
import dateNoteService from "../services/date_notes.js";
import treeService from "../services/tree.js";
import openService from "./open.js";
export default class DialogCommandExecutor extends Component {
export default class RootCommandExecutor extends Component {
jumpToNoteCommand() {
import("../dialogs/jump_to_note.js").then(d => d.showDialog());
}
@ -84,4 +85,12 @@ export default class DialogCommandExecutor extends Component {
showBackendLogCommand() {
import("../dialogs/backend_log.js").then(d => d.showDialog());
}
openNoteExternallyCommand() {
const noteId = appContext.tabManager.getActiveTabNoteId();
if (noteId) {
openService.openNoteExternally(noteId);
}
}
}

View File

@ -22,6 +22,7 @@ const TPL = `
padding-left: 10px;
padding-right: 10px;
position: relative;
top: -2px;
border-radius: 0;
}

View File

@ -1,6 +1,6 @@
import TabAwareWidget from "./tab_aware_widget.js";
import protectedSessionService from "../services/protected_session.js";
import openService from "../services/open.js";
import utils from "../services/utils.js";
const TPL = `
<div class="dropdown note-actions">
@ -123,7 +123,6 @@ export default class NoteActionsWidget extends TabAwareWidget {
() => this.$widget.find('.dropdown-toggle').dropdown('toggle'));
this.$openNoteExternallyButton = this.$widget.find(".open-note-externally-button");
this.$openNoteExternallyButton.on('click', () => openService.openNoteExternally(this.noteId));
}
refreshWithNote(note) {
@ -133,6 +132,8 @@ export default class NoteActionsWidget extends TabAwareWidget {
this.$protectButton.toggle(!note.isProtected);
this.$unprotectButton.toggle(!!note.isProtected);
this.$openNoteExternallyButton.toggle(utils.isElectron());
}
toggleDisabled($el, enable) {