Notes/src/public/app/services/root_command_executor.js

118 lines
3.5 KiB
JavaScript
Raw Normal View History

2020-01-20 22:35:52 +01:00
import Component from "../widgets/component.js";
2020-02-17 22:14:39 +01:00
import appContext from "./app_context.js";
import dateNoteService from "../services/date_notes.js";
2020-12-05 23:00:28 +01:00
import treeService from "../services/tree.js";
import openService from "./open.js";
2021-05-18 22:14:35 +02:00
import protectedSessionService from "./protected_session.js";
import options from "./options.js";
2020-01-20 22:35:52 +01:00
export default class RootCommandExecutor extends Component {
2020-02-15 10:41:21 +01:00
jumpToNoteCommand() {
2020-01-20 22:35:52 +01:00
import("../dialogs/jump_to_note.js").then(d => d.showDialog());
}
2020-02-15 10:41:21 +01:00
showRecentChangesCommand() {
2020-01-20 22:35:52 +01:00
import("../dialogs/recent_changes.js").then(d => d.showDialog());
}
2020-02-15 10:41:21 +01:00
showNoteRevisionsCommand() {
2020-01-20 22:35:52 +01:00
import("../dialogs/note_revisions.js").then(d => d.showCurrentNoteRevisions());
}
2020-02-15 10:41:21 +01:00
showNoteSourceCommand() {
2020-01-20 22:35:52 +01:00
import("../dialogs/note_source.js").then(d => d.showDialog());
}
2020-02-15 10:41:21 +01:00
pasteMarkdownIntoTextCommand() {
2020-01-20 22:35:52 +01:00
import("../dialogs/markdown_import.js").then(d => d.importMarkdownInline());
}
2020-02-15 10:41:21 +01:00
async editBranchPrefixCommand() {
2021-05-22 12:35:41 +02:00
const notePath = appContext.tabManager.getActiveContextNotePath();
2020-01-20 22:35:52 +01:00
2020-02-14 21:21:47 +01:00
if (notePath) {
const editBranchPrefixDialog = await import("../dialogs/branch_prefix.js");
editBranchPrefixDialog.showDialog(notePath);
}
2020-01-20 22:35:52 +01:00
}
editReadOnlyNoteCommand() {
const noteContext = appContext.tabManager.getActiveContext();
noteContext.readOnlyTemporarilyDisabled = true;
appContext.triggerEvent("readOnlyTemporarilyDisabled", { noteContext });
}
2020-02-15 18:41:32 +01:00
async cloneNoteIdsToCommand({noteIds}) {
const d = await import("../dialogs/clone_to.js");
d.showDialog(noteIds);
}
2020-02-15 10:41:21 +01:00
async moveBranchIdsToCommand({branchIds}) {
const d = await import("../dialogs/move_to.js");
d.showDialog(branchIds);
}
showOptionsCommand({openTab}) {
import("../dialogs/options.js").then(d => d.showDialog(openTab));
}
showHelpCommand() {
import("../dialogs/help.js").then(d => d.showDialog());
}
async showSQLConsoleCommand() {
const sqlConsoleNote = await dateNoteService.createSqlConsole();
2021-05-22 12:35:41 +02:00
const noteContext = await appContext.tabManager.openContextWithNote(sqlConsoleNote.noteId, true);
2021-05-22 12:26:45 +02:00
appContext.triggerEvent('focusOnDetail', {ntxId: noteContext.ntxId});
}
async searchNotesCommand({searchString, ancestorNoteId}) {
const searchNote = await dateNoteService.createSearchNote({searchString, ancestorNoteId});
2021-05-22 12:35:41 +02:00
const noteContext = await appContext.tabManager.openContextWithNote(searchNote.noteId, true);
2021-05-22 12:26:45 +02:00
appContext.triggerCommand('focusOnSearchDefinition', {ntxId: noteContext.ntxId});
}
2020-12-05 23:00:28 +01:00
async searchInSubtreeCommand({notePath}) {
const noteId = treeService.getNoteIdFromNotePath(notePath);
this.searchNotesCommand({ancestorNoteId: noteId});
2020-12-05 23:00:28 +01:00
}
showBackendLogCommand() {
import("../dialogs/backend_log.js").then(d => d.showDialog());
}
openNoteExternallyCommand() {
2021-05-22 12:35:41 +02:00
const noteId = appContext.tabManager.getActiveContextNoteId();
if (noteId) {
openService.openNoteExternally(noteId);
}
}
2021-05-18 22:14:35 +02:00
enterProtectedSessionCommand() {
protectedSessionService.enterProtectedSession();
}
leaveProtectedSessionCommand() {
protectedSessionService.leaveProtectedSession();
}
hideLeftPaneCommand() {
options.save(`leftPaneVisible`, "false");
}
showLeftPaneCommand() {
options.save(`leftPaneVisible`, "true");
}
toggleLeftPaneCommand() {
options.toggle('leftPaneVisible');
}
2020-07-04 10:18:01 +02:00
}