mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
binding remaining actions
This commit is contained in:
parent
ff3f0ee0a0
commit
d21e824343
@ -8,6 +8,7 @@ import utils from "./utils.js";
|
||||
import contextMenuService from "./context_menu.js";
|
||||
import treeUtils from "./tree_utils.js";
|
||||
import tabRow from "./tab_row.js";
|
||||
import keyboardActionService from "./keyboard_actions.js";
|
||||
|
||||
const $tabContentsContainer = $("#note-tab-container");
|
||||
const $savedIndicator = $(".saved-indicator");
|
||||
@ -419,33 +420,31 @@ $(tabRow.el).on('contextmenu', '.note-tab', e => {
|
||||
});
|
||||
});
|
||||
|
||||
if (utils.isElectron()) {
|
||||
utils.bindGlobalShortcut('ctrl+t', () => {
|
||||
openEmptyTab();
|
||||
});
|
||||
keyboardActionService.setActionHandler('OpenNewTab', () => {
|
||||
openEmptyTab();
|
||||
});
|
||||
|
||||
utils.bindGlobalShortcut('ctrl+w', () => {
|
||||
if (tabRow.activeTabEl) {
|
||||
tabRow.removeTab(tabRow.activeTabEl);
|
||||
}
|
||||
});
|
||||
keyboardActionService.setActionHandler('CloseActiveTab', () => {
|
||||
if (tabRow.activeTabEl) {
|
||||
tabRow.removeTab(tabRow.activeTabEl);
|
||||
}
|
||||
});
|
||||
|
||||
utils.bindGlobalShortcut('ctrl+tab', () => {
|
||||
const nextTab = tabRow.nextTabEl;
|
||||
keyboardActionService.setActionHandler('ActivateNextTab', () => {
|
||||
const nextTab = tabRow.nextTabEl;
|
||||
|
||||
if (nextTab) {
|
||||
tabRow.activateTab(nextTab);
|
||||
}
|
||||
});
|
||||
if (nextTab) {
|
||||
tabRow.activateTab(nextTab);
|
||||
}
|
||||
});
|
||||
|
||||
utils.bindGlobalShortcut('ctrl+shift+tab', () => {
|
||||
const prevTab = tabRow.previousTabEl;
|
||||
keyboardActionService.setActionHandler('ActivatePreviousTab', () => {
|
||||
const prevTab = tabRow.previousTabEl;
|
||||
|
||||
if (prevTab) {
|
||||
tabRow.activateTab(prevTab);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (prevTab) {
|
||||
tabRow.activateTab(prevTab);
|
||||
}
|
||||
});
|
||||
|
||||
tabRow.addListener('activeTabChange', openTabsChanged);
|
||||
tabRow.addListener('tabRemove', openTabsChanged);
|
||||
|
@ -14,6 +14,7 @@ import hoistedNoteService from '../services/hoisted_note.js';
|
||||
import optionsService from "../services/options.js";
|
||||
import TreeContextMenu from "./tree_context_menu.js";
|
||||
import bundle from "./bundle.js";
|
||||
import keyboardActionService from "./keyboard_actions.js";
|
||||
|
||||
const $tree = $("#tree");
|
||||
const $createTopLevelNoteButton = $("#create-top-level-note-button");
|
||||
@ -795,7 +796,7 @@ ws.subscribeToOutsideSyncMessages(async syncData => {
|
||||
}
|
||||
});
|
||||
|
||||
utils.bindGlobalShortcut('ctrl+o', async () => {
|
||||
keyboardActionService.setActionHandler('CreateNoteAfter', async () => {
|
||||
const node = getActiveNode();
|
||||
const parentNoteId = node.data.parentNoteId;
|
||||
const isProtected = await treeUtils.getParentProtectedStatus(node);
|
||||
@ -867,9 +868,9 @@ async function reloadNotes(noteIds, activateNotePath = null) {
|
||||
|
||||
window.glob.createNoteInto = createNoteInto;
|
||||
|
||||
utils.bindGlobalShortcut('ctrl+p', createNoteInto);
|
||||
keyboardActionService.setActionHandler('CreateNoteInto', createNoteInto);
|
||||
|
||||
utils.bindGlobalShortcut('ctrl+.', scrollToActiveNote);
|
||||
keyboardActionService.setActionHandler('ScrollToActiveNote', scrollToActiveNote);
|
||||
|
||||
$(window).bind('hashchange', async function() {
|
||||
if (isNotePathInAddress()) {
|
||||
@ -907,7 +908,7 @@ async function duplicateNote(noteId, parentNoteId) {
|
||||
}
|
||||
|
||||
|
||||
utils.bindGlobalShortcut('alt+c', () => collapseTree()); // don't use shortened form since collapseTree() accepts argument
|
||||
keyboardActionService.setActionHandler('CollapseTree', () => collapseTree()); // don't use shortened form since collapseTree() accepts argument
|
||||
$collapseTreeButton.on('click', () => collapseTree());
|
||||
|
||||
$createTopLevelNoteButton.on('click', createNewTopLevelNote);
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
const optionService = require('./options');
|
||||
const log = require('./log');
|
||||
const utils = require('./utils');
|
||||
|
||||
const ELECTRON = "electron";
|
||||
const isMac = process.platform === "darwin";
|
||||
const isElectron = utils.isElectron();
|
||||
|
||||
const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
{
|
||||
@ -11,11 +13,13 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
},
|
||||
{
|
||||
actionName: "BackInNoteHistory",
|
||||
defaultShortcuts: ["Alt+Left"]
|
||||
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
|
||||
defaultShortcuts: isMac ? ["Meta+Left"] : ["Alt+Left"]
|
||||
},
|
||||
{
|
||||
actionName: "ForwardInNoteHistory",
|
||||
defaultShortcuts: ["Alt+Right"]
|
||||
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
|
||||
defaultShortcuts: isMac ? ["Meta+Right"] : ["Alt+Right"]
|
||||
},
|
||||
{
|
||||
actionName: "JumpToNote",
|
||||
@ -29,23 +33,19 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
},
|
||||
{
|
||||
actionName: "OpenNewTab",
|
||||
defaultShortcuts: ["CommandOrControl+T"],
|
||||
only: ELECTRON
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+T"] : []
|
||||
},
|
||||
{
|
||||
actionName: "CloseActiveTab",
|
||||
defaultShortcuts: ["CommandOrControl+W"],
|
||||
only: ELECTRON
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+W"] : []
|
||||
},
|
||||
{
|
||||
actionName: "ActivateNextTab",
|
||||
defaultShortcuts: ["CommandOrControl+Tab"],
|
||||
only: ELECTRON
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+Tab"] : []
|
||||
},
|
||||
{
|
||||
actionName: "ActivatePreviousTab",
|
||||
defaultShortcuts: ["CommandOrControl+Shift+Tab"],
|
||||
only: ELECTRON
|
||||
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab"] : []
|
||||
},
|
||||
|
||||
|
||||
@ -269,22 +269,11 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
}
|
||||
];
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||
if (action.defaultShortcuts) {
|
||||
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("CommandOrControl", "Meta"));
|
||||
}
|
||||
}
|
||||
const platformModifier = isMac ? 'Meta' : 'Ctrl';
|
||||
|
||||
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
|
||||
DEFAULT_KEYBOARD_ACTIONS.find(ka => ka.actionName === 'BackInNoteHistory').defaultShortcuts = ["Meta+Left"];
|
||||
DEFAULT_KEYBOARD_ACTIONS.find(ka => ka.actionName === 'ForwardInNoteHistory').defaultShortcuts = ["Meta+Right"];
|
||||
}
|
||||
else {
|
||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||
if (action.defaultShortcuts) {
|
||||
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("CommandOrControl", "Ctrl"));
|
||||
}
|
||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||
if (action.defaultShortcuts) {
|
||||
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("CommandOrControl", platformModifier));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user