mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	further refactorings, got rid of init.js
This commit is contained in:
		
							
								
								
									
										130
									
								
								src/public/javascripts/services/entrypoints.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										130
									
								
								src/public/javascripts/services/entrypoints.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,130 @@ | ||||
| import utils from "./utils.js"; | ||||
| import treeService from "./tree.js"; | ||||
| import linkService from "./link.js"; | ||||
| import attachmentService from "./attachment.js"; | ||||
| import noteRevisionsDialog from "../dialogs/note_revisions.js"; | ||||
| import settingsDialog from "../dialogs/settings.js"; | ||||
| import addLinkDialog from "../dialogs/add_link.js"; | ||||
| import recentNotesDialog from "../dialogs/recent_notes.js"; | ||||
| import jumpToNoteDialog from "../dialogs/jump_to_note.js"; | ||||
| import noteSourceDialog from "../dialogs/note_source.js"; | ||||
| import recentChangesDialog from "../dialogs/recent_changes.js"; | ||||
| import sqlConsoleDialog from "../dialogs/sql_console.js"; | ||||
| import searchTreeService from "./search_tree.js"; | ||||
| import labelsDialog from "../dialogs/labels.js"; | ||||
|  | ||||
| function registerEntrypoints() { | ||||
|     // 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; | ||||
|  | ||||
|     utils.bindShortcut('ctrl+l', addLinkDialog.showDialog); | ||||
|  | ||||
|     $("#jump-to-note-button").click(jumpToNoteDialog.showDialog); | ||||
|     utils.bindShortcut('ctrl+j', jumpToNoteDialog.showDialog); | ||||
|  | ||||
|     $("#show-note-revisions-button").click(noteRevisionsDialog.showCurrentNoteRevisions); | ||||
|  | ||||
|     $("#show-source-button").click(noteSourceDialog.showDialog); | ||||
|     utils.bindShortcut('ctrl+u', noteSourceDialog.showDialog); | ||||
|  | ||||
|     $("#recent-changes-button").click(recentChangesDialog.showDialog); | ||||
|  | ||||
|     $("#recent-notes-button").click(recentNotesDialog.showDialog); | ||||
|     utils.bindShortcut('ctrl+e', recentNotesDialog.showDialog); | ||||
|  | ||||
|     $("#toggle-search-button").click(searchTreeService.toggleSearch); | ||||
|     utils.bindShortcut('ctrl+s', searchTreeService.toggleSearch); | ||||
|  | ||||
|     $(".show-labels-button").click(labelsDialog.showDialog); | ||||
|     utils.bindShortcut('alt+l', labelsDialog.showDialog); | ||||
|  | ||||
|     $("#settings-button").click(settingsDialog.showDialog); | ||||
|  | ||||
|     utils.bindShortcut('alt+o', sqlConsoleDialog.showDialog); | ||||
|  | ||||
|     if (utils.isElectron()) { | ||||
|         utils.bindShortcut('alt+left', window.history.back); | ||||
|         utils.bindShortcut('alt+right', window.history.forward); | ||||
|     } | ||||
|  | ||||
|     utils.bindShortcut('alt+m', e => $(".hide-toggle").toggleClass("suppressed")); | ||||
|  | ||||
|     // hide (toggle) everything except for the note content for distraction free writing | ||||
|     utils.bindShortcut('alt+t', e => { | ||||
|         const date = new Date(); | ||||
|         const dateString = utils.formatDateTime(date); | ||||
|  | ||||
|         linkService.addTextToEditor(dateString); | ||||
|     }); | ||||
|  | ||||
|     utils.bindShortcut('f5', utils.reloadApp); | ||||
|  | ||||
|     utils.bindShortcut('ctrl+r', utils.reloadApp); | ||||
|  | ||||
|     $(document).bind('keydown', 'ctrl+shift+i', () => { | ||||
|         if (utils.isElectron()) { | ||||
|             require('electron').remote.getCurrentWindow().toggleDevTools(); | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     $(document).bind('keydown', 'ctrl+f', () => { | ||||
|         if (utils.isElectron()) { | ||||
|             const searchInPage = require('electron-in-page-search').default; | ||||
|             const remote = require('electron').remote; | ||||
|  | ||||
|             const inPageSearch = searchInPage(remote.getCurrentWebContents()); | ||||
|  | ||||
|             inPageSearch.openSearchWindow(); | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     utils.bindShortcut("ctrl+shift+up", () => { | ||||
|         const node = treeService.getCurrentNode(); | ||||
|         node.navigate($.ui.keyCode.UP, true); | ||||
|  | ||||
|         $("#note-detail").focus(); | ||||
|     }); | ||||
|  | ||||
|     utils.bindShortcut("ctrl+shift+down", () => { | ||||
|         const node = treeService.getCurrentNode(); | ||||
|         node.navigate($.ui.keyCode.DOWN, true); | ||||
|  | ||||
|         $("#note-detail").focus(); | ||||
|     }); | ||||
|  | ||||
|     $(document).bind('keydown', 'ctrl+-', () => { | ||||
|         if (utils.isElectron()) { | ||||
|             const webFrame = require('electron').webFrame; | ||||
|  | ||||
|             if (webFrame.getZoomFactor() > 0.2) { | ||||
|                 webFrame.setZoomFactor(webFrame.getZoomFactor() - 0.1); | ||||
|             } | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     $(document).bind('keydown', 'ctrl+=', () => { | ||||
|         if (utils.isElectron()) { | ||||
|             const webFrame = require('electron').webFrame; | ||||
|  | ||||
|             webFrame.setZoomFactor(webFrame.getZoomFactor() + 0.1); | ||||
|  | ||||
|             return false; | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     $("#note-title").bind('keydown', 'return', () => $("#note-detail").focus()); | ||||
|  | ||||
|     $("#upload-attachment-button").click(attachmentService.uploadAttachment); | ||||
| } | ||||
|  | ||||
| export default { | ||||
|     registerEntrypoints | ||||
| } | ||||
		Reference in New Issue
	
	Block a user