mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-18 16:32:33 +08:00
server: Fix crash when starting server in Docker due to translations
This commit is contained in:
parent
5c44ac5ad8
commit
e45c5f429d
@ -18,11 +18,12 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!t("keyboard_actions.note-navigation")) {
|
function getDefaultKeyboardActions() {
|
||||||
|
if (!t("keyboard_actions.note-navigation")) {
|
||||||
throw new Error("Keyboard actions loaded before translations.");
|
throw new Error("Keyboard actions loaded before translations.");
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [
|
const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [
|
||||||
{
|
{
|
||||||
separator: t("keyboard_actions.note-navigation")
|
separator: t("keyboard_actions.note-navigation")
|
||||||
},
|
},
|
||||||
@ -600,18 +601,24 @@ const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [
|
|||||||
description: t("keyboard_actions.force-save-revision"),
|
description: t("keyboard_actions.force-save-revision"),
|
||||||
scope: "window"
|
scope: "window"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const platformModifier = isMac ? 'Meta' : 'Ctrl';
|
/*
|
||||||
|
* Apply macOS-specific tweaks.
|
||||||
|
*/
|
||||||
|
const platformModifier = isMac ? 'Meta' : 'Ctrl';
|
||||||
|
|
||||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||||
if (action.defaultShortcuts) {
|
if (action.defaultShortcuts) {
|
||||||
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("CommandOrControl", platformModifier));
|
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("CommandOrControl", platformModifier));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return DEFAULT_KEYBOARD_ACTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getKeyboardActions() {
|
function getKeyboardActions() {
|
||||||
const actions: KeyboardShortcut[] = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
|
const actions: KeyboardShortcut[] = JSON.parse(JSON.stringify(getDefaultKeyboardActions()));
|
||||||
|
|
||||||
for (const action of actions) {
|
for (const action of actions) {
|
||||||
action.effectiveShortcuts = action.defaultShortcuts ? action.defaultShortcuts.slice() : [];
|
action.effectiveShortcuts = action.defaultShortcuts ? action.defaultShortcuts.slice() : [];
|
||||||
@ -642,6 +649,6 @@ function getKeyboardActions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
DEFAULT_KEYBOARD_ACTIONS,
|
getDefaultKeyboardActions,
|
||||||
getKeyboardActions
|
getKeyboardActions
|
||||||
};
|
};
|
||||||
|
@ -126,7 +126,7 @@ function initStartupOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getKeyboardDefaultOptions() {
|
function getKeyboardDefaultOptions() {
|
||||||
return (keyboardActions.DEFAULT_KEYBOARD_ACTIONS
|
return (keyboardActions.getDefaultKeyboardActions()
|
||||||
.filter(ka => !!ka.actionName) as KeyboardShortcutWithRequiredActionName[])
|
.filter(ka => !!ka.actionName) as KeyboardShortcutWithRequiredActionName[])
|
||||||
.map(ka => ({
|
.map(ka => ({
|
||||||
name: `keyboardShortcuts${ka.actionName.charAt(0).toUpperCase()}${ka.actionName.slice(1)}`,
|
name: `keyboardShortcuts${ka.actionName.charAt(0).toUpperCase()}${ka.actionName.slice(1)}`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user