mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	server-ts: Port keyboard_actions
This commit is contained in:
		
							parent
							
								
									5916a8b5b8
								
							
						
					
					
						commit
						6b8ee084e6
					
				@ -1,6 +1,6 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
const keyboardActions = require('../../services/keyboard_actions.js');
 | 
			
		||||
const keyboardActions = require('../../services/keyboard_actions');
 | 
			
		||||
const becca = require('../../becca/becca');
 | 
			
		||||
 | 
			
		||||
function getKeyboardActions() {
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,21 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
 | 
			
		||||
const optionService = require('./options');
 | 
			
		||||
const log = require('./log');
 | 
			
		||||
const utils = require('./utils');
 | 
			
		||||
import optionService = require('./options');
 | 
			
		||||
import log = require('./log');
 | 
			
		||||
import utils = require('./utils');
 | 
			
		||||
 | 
			
		||||
const isMac = process.platform === "darwin";
 | 
			
		||||
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,
 | 
			
		||||
 * 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.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
const DEFAULT_KEYBOARD_ACTIONS = [
 | 
			
		||||
const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [
 | 
			
		||||
    {
 | 
			
		||||
        separator: "Note navigation"
 | 
			
		||||
    },
 | 
			
		||||
@ -606,10 +615,10 @@ for (const action of DEFAULT_KEYBOARD_ACTIONS) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
        action.effectiveShortcuts = action.effectiveShortcuts ? action.defaultShortcuts.slice() : [];
 | 
			
		||||
        action.effectiveShortcuts = action.defaultShortcuts ? action.defaultShortcuts.slice() : [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    for (const option of optionService.getOptions()) {
 | 
			
		||||
@ -636,7 +645,7 @@ function getKeyboardActions() {
 | 
			
		||||
    return actions;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
export = {
 | 
			
		||||
    DEFAULT_KEYBOARD_ACTIONS,
 | 
			
		||||
    getKeyboardActions
 | 
			
		||||
};
 | 
			
		||||
@ -3,7 +3,7 @@ const appInfo = require('./app_info');
 | 
			
		||||
const utils = require('./utils');
 | 
			
		||||
const log = require('./log');
 | 
			
		||||
const dateUtils = require('./date_utils');
 | 
			
		||||
const keyboardActions = require('./keyboard_actions.js');
 | 
			
		||||
const keyboardActions = require('./keyboard_actions');
 | 
			
		||||
 | 
			
		||||
function initDocumentOptions() {
 | 
			
		||||
    optionService.createOption('documentId', utils.randomSecureToken(16), false);
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@ const env = require('./env');
 | 
			
		||||
const log = require('./log');
 | 
			
		||||
const sqlInit = require('./sql_init.js');
 | 
			
		||||
const cls = require('./cls');
 | 
			
		||||
const keyboardActionsService = require('./keyboard_actions.js');
 | 
			
		||||
const keyboardActionsService = require('./keyboard_actions');
 | 
			
		||||
const {ipcMain} = require('electron');
 | 
			
		||||
 | 
			
		||||
// Prevent the window being garbage collected
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user