mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	server-ts: Port keyboard_actions
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
|  |  | ||||||
| const keyboardActions = require('../../services/keyboard_actions.js'); | const keyboardActions = require('../../services/keyboard_actions'); | ||||||
| const becca = require('../../becca/becca'); | const becca = require('../../becca/becca'); | ||||||
|  |  | ||||||
| function getKeyboardActions() { | function getKeyboardActions() { | ||||||
|   | |||||||
| @@ -1,12 +1,21 @@ | |||||||
| "use strict"; | "use strict"; | ||||||
| 
 | 
 | ||||||
| const optionService = require('./options'); | import optionService = require('./options'); | ||||||
| const log = require('./log'); | import log = require('./log'); | ||||||
| const utils = require('./utils'); | import utils = require('./utils'); | ||||||
| 
 | 
 | ||||||
| const isMac = process.platform === "darwin"; | const isMac = process.platform === "darwin"; | ||||||
| const isElectron = utils.isElectron(); | const isElectron = utils.isElectron(); | ||||||
| 
 | 
 | ||||||
|  | interface KeyboardShortcut { | ||||||
|  |     separator?: string; | ||||||
|  |     actionName?: string; | ||||||
|  |     description?: string; | ||||||
|  |     defaultShortcuts?: string[]; | ||||||
|  |     effectiveShortcuts?: string[]; | ||||||
|  |     scope?: string; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /** | /** | ||||||
|  * Scope here means on which element the keyboard shortcuts are attached - this means that for the shortcut to work, |  * Scope here means on which element the keyboard shortcuts are attached - this means that for the shortcut to work, | ||||||
|  * the focus has to be inside the element. |  * the focus has to be inside the element. | ||||||
| @@ -16,7 +25,7 @@ const isElectron = utils.isElectron(); | |||||||
|  * e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor. |  * e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| const DEFAULT_KEYBOARD_ACTIONS = [ | const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [ | ||||||
|     { |     { | ||||||
|         separator: "Note navigation" |         separator: "Note navigation" | ||||||
|     }, |     }, | ||||||
| @@ -606,10 +615,10 @@ for (const action of DEFAULT_KEYBOARD_ACTIONS) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function getKeyboardActions() { | function getKeyboardActions() { | ||||||
|     const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS)); |     const actions: KeyboardShortcut[] = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS)); | ||||||
| 
 | 
 | ||||||
|     for (const action of actions) { |     for (const action of actions) { | ||||||
|         action.effectiveShortcuts = action.effectiveShortcuts ? action.defaultShortcuts.slice() : []; |         action.effectiveShortcuts = action.defaultShortcuts ? action.defaultShortcuts.slice() : []; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     for (const option of optionService.getOptions()) { |     for (const option of optionService.getOptions()) { | ||||||
| @@ -636,7 +645,7 @@ function getKeyboardActions() { | |||||||
|     return actions; |     return actions; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| module.exports = { | export = { | ||||||
|     DEFAULT_KEYBOARD_ACTIONS, |     DEFAULT_KEYBOARD_ACTIONS, | ||||||
|     getKeyboardActions |     getKeyboardActions | ||||||
| }; | }; | ||||||
| @@ -3,7 +3,7 @@ const appInfo = require('./app_info'); | |||||||
| const utils = require('./utils'); | const utils = require('./utils'); | ||||||
| const log = require('./log'); | const log = require('./log'); | ||||||
| const dateUtils = require('./date_utils'); | const dateUtils = require('./date_utils'); | ||||||
| const keyboardActions = require('./keyboard_actions.js'); | const keyboardActions = require('./keyboard_actions'); | ||||||
|  |  | ||||||
| function initDocumentOptions() { | function initDocumentOptions() { | ||||||
|     optionService.createOption('documentId', utils.randomSecureToken(16), false); |     optionService.createOption('documentId', utils.randomSecureToken(16), false); | ||||||
|   | |||||||
| @@ -6,7 +6,7 @@ const env = require('./env'); | |||||||
| const log = require('./log'); | const log = require('./log'); | ||||||
| const sqlInit = require('./sql_init.js'); | const sqlInit = require('./sql_init.js'); | ||||||
| const cls = require('./cls'); | const cls = require('./cls'); | ||||||
| const keyboardActionsService = require('./keyboard_actions.js'); | const keyboardActionsService = require('./keyboard_actions'); | ||||||
| const {ipcMain} = require('electron'); | const {ipcMain} = require('electron'); | ||||||
|  |  | ||||||
| // Prevent the window being garbage collected | // Prevent the window being garbage collected | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user