import utils from "../services/utils.js"; import dateNoteService from "../services/date_notes.js"; import protectedSessionHolder from '../services/protected_session_holder.js'; import server from "../services/server.js"; import appContext from "./app_context.js"; import Component from "./component.js"; import toastService from "../services/toast.js"; import ws from "../services/ws.js"; import bundleService from "../services/bundle.js"; import froca from "../services/froca.js"; export default class Entrypoints extends Component { constructor() { super(); if (jQuery.hotkeys) { // hot keys are active also inside inputs and content editables jQuery.hotkeys.options.filterInputAcceptingElements = false; jQuery.hotkeys.options.filterContentEditable = false; jQuery.hotkeys.options.filterTextInputs = false; } } openDevToolsCommand() { if (utils.isElectron()) { utils.dynamicRequire('@electron/remote').getCurrentWindow().toggleDevTools(); } } async createNoteIntoInboxCommand() { const inboxNote = await dateNoteService.getInboxNote(); const {note} = await server.post(`notes/${inboxNote.noteId}/children?target=into`, { content: '', type: 'text', isProtected: inboxNote.isProtected && protectedSessionHolder.isProtectedSessionAvailable() }); await ws.waitForMaxKnownEntityChangeId(); await appContext.tabManager.openTabWithNoteWithHoisting(note.noteId, true); appContext.triggerEvent('focusAndSelectTitle', {isNewNote: true}); } async toggleNoteHoistingCommand({noteId = appContext.tabManager.getActiveContextNoteId()}) { const noteToHoist = await froca.getNote(noteId); const activeNoteContext = appContext.tabManager.getActiveContext(); if (noteToHoist.noteId === activeNoteContext.hoistedNoteId) { await activeNoteContext.unhoist(); } else if (noteToHoist.type !== 'search') { await activeNoteContext.setHoistedNoteId(noteId); } } async hoistNoteCommand({noteId}) { const noteContext = appContext.tabManager.getActiveContext(); if (noteContext.hoistedNoteId !== noteId) { await noteContext.setHoistedNoteId(noteId); } } async unhoistCommand() { const activeNoteContext = appContext.tabManager.getActiveContext(); if (activeNoteContext) { activeNoteContext.unhoist(); } } copyWithoutFormattingCommand() { utils.copySelectionToClipboard(); } toggleFullscreenCommand() { if (utils.isElectron()) { const win = utils.dynamicRequire('@electron/remote').getCurrentWindow(); if (win.isFullScreenable()) { win.setFullScreen(!win.isFullScreen()); } } // outside of electron this is handled by the browser } reloadFrontendAppCommand() { utils.reloadFrontendApp(); } logoutCommand() { const $logoutForm = $('