mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 14:49:57 +02:00
Fixing macOS keybind issues
This commit is contained in:
parent
6ab00d24f8
commit
4955c19c25
1 changed files with 347 additions and 159 deletions
|
@ -3,174 +3,349 @@ const kZKSActions = {
|
||||||
// otherwise "oncommand=" will be added.
|
// otherwise "oncommand=" will be added.
|
||||||
|
|
||||||
// Split view actions
|
// Split view actions
|
||||||
zenSplitViewGrid: ["gZenViewSplitter.toggleShortcut('grid')", 'zen-split-view-grid', 'split-view-action'],
|
zenSplitViewGrid: [
|
||||||
zenSplitViewVertical: ["gZenViewSplitter.toggleShortcut('vsep')", 'zen-split-view-vertical', 'split-view-action'],
|
"gZenViewSplitter.toggleShortcut('grid')",
|
||||||
zenSplitViewHorizontal: ["gZenViewSplitter.toggleShortcut('hsep')", 'zen-split-view-horizontal', 'split-view-action'],
|
"zen-split-view-grid",
|
||||||
zenSplitViewClose: ["gZenViewSplitter.toggleShortcut('unsplit')", 'zen-split-view-close', 'split-view-action'],
|
"split-view-action",
|
||||||
|
],
|
||||||
|
zenSplitViewVertical: [
|
||||||
|
"gZenViewSplitter.toggleShortcut('vsep')",
|
||||||
|
"zen-split-view-vertical",
|
||||||
|
"split-view-action",
|
||||||
|
],
|
||||||
|
zenSplitViewHorizontal: [
|
||||||
|
"gZenViewSplitter.toggleShortcut('hsep')",
|
||||||
|
"zen-split-view-horizontal",
|
||||||
|
"split-view-action",
|
||||||
|
],
|
||||||
|
zenSplitViewClose: [
|
||||||
|
"gZenViewSplitter.toggleShortcut('unsplit')",
|
||||||
|
"zen-split-view-close",
|
||||||
|
"split-view-action",
|
||||||
|
],
|
||||||
|
|
||||||
// Workspace actions
|
// Workspace actions
|
||||||
zenChangeWorkspace: ['ZenWorkspaces.changeWorkspaceShortcut()', 'zen-change-workspace', 'workspace-action'],
|
zenChangeWorkspace: [
|
||||||
|
"ZenWorkspaces.changeWorkspaceShortcut()",
|
||||||
|
"zen-change-workspace",
|
||||||
|
"workspace-action",
|
||||||
|
],
|
||||||
|
|
||||||
// manage actions
|
// manage actions
|
||||||
openNewTab: ['command:cmd_newNavigatorTabNoEvent', 'open-new-tab', 'tab-action'],
|
openNewTab: [
|
||||||
duplicateTab: ["duplicateTabIn(gBrowser.selectedTab, 'tab')", 'duplicate-tab', 'tab-action'],
|
"command:cmd_newNavigatorTabNoEvent",
|
||||||
closeTab: ['command:cmd_close', 'close-tab', 'tab-action'],
|
"open-new-tab",
|
||||||
openNewWindow: ['command:cmd_newNavigator', 'open-new-window', 'tab-action'],
|
"tab-action",
|
||||||
openNewPrivateWindow: ['command:Tools:PrivateBrowsing', 'open-new-private-window', 'tab-action'],
|
],
|
||||||
closeWindow: ['command:cmd_closeWindow', 'close-window', 'tab-action'],
|
duplicateTab: [
|
||||||
restoreLastTab: ['undoCloseTab()', 'restore-last-session', 'tab-action'],
|
"duplicateTabIn(gBrowser.selectedTab, 'tab')",
|
||||||
restoreLastWindow: ['command:History:UndoCloseWindow', 'restore-last-window', 'tab-action'],
|
"duplicate-tab",
|
||||||
showNextTab: ['gBrowser.tabContainer.advanceSelectedTab(1, true)', 'show-next-tab', 'tab-action'],
|
"tab-action",
|
||||||
showPreviousTab: ['gBrowser.tabContainer.advanceSelectedTab(-1, true)', 'show-previous-tab', 'tab-action'],
|
],
|
||||||
showAllTabsPanel: ['gTabsPanel.showAllTabsPanel()', 'show-all-tabs-panel', 'tab-action'],
|
closeTab: ["command:cmd_close", "close-tab", "tab-action"],
|
||||||
|
openNewWindow: ["command:cmd_newNavigator", "open-new-window", "tab-action"],
|
||||||
|
openNewPrivateWindow: [
|
||||||
|
"command:Tools:PrivateBrowsing",
|
||||||
|
"open-new-private-window",
|
||||||
|
"tab-action",
|
||||||
|
],
|
||||||
|
closeWindow: ["command:cmd_closeWindow", "close-window", "tab-action"],
|
||||||
|
restoreLastTab: ["undoCloseTab()", "restore-last-session", "tab-action"],
|
||||||
|
restoreLastWindow: [
|
||||||
|
"command:History:UndoCloseWindow",
|
||||||
|
"restore-last-window",
|
||||||
|
"tab-action",
|
||||||
|
],
|
||||||
|
showNextTab: [
|
||||||
|
"gBrowser.tabContainer.advanceSelectedTab(1, true)",
|
||||||
|
"show-next-tab",
|
||||||
|
"tab-action",
|
||||||
|
],
|
||||||
|
showPreviousTab: [
|
||||||
|
"gBrowser.tabContainer.advanceSelectedTab(-1, true)",
|
||||||
|
"show-previous-tab",
|
||||||
|
"tab-action",
|
||||||
|
],
|
||||||
|
showAllTabsPanel: [
|
||||||
|
"gTabsPanel.showAllTabsPanel()",
|
||||||
|
"show-all-tabs-panel",
|
||||||
|
"tab-action",
|
||||||
|
],
|
||||||
|
|
||||||
// Compact mode actions
|
// Compact mode actions
|
||||||
zenToggleCompactMode: ['gZenCompactModeManager.toggle()', 'zen-toggle-compact-mode', 'compact-mode-action'],
|
zenToggleCompactMode: [
|
||||||
|
"gZenCompactModeManager.toggle()",
|
||||||
|
"zen-toggle-compact-mode",
|
||||||
|
"compact-mode-action",
|
||||||
|
],
|
||||||
zenToggleCompactModeSidebar: [
|
zenToggleCompactModeSidebar: [
|
||||||
'gZenCompactModeManager.toggleSidebar()',
|
"gZenCompactModeManager.toggleSidebar()",
|
||||||
'zen-toggle-compact-mode-sidebar',
|
"zen-toggle-compact-mode-sidebar",
|
||||||
'compact-mode-action',
|
"compact-mode-action",
|
||||||
],
|
],
|
||||||
zenToggleCompactModeToolbar: [
|
zenToggleCompactModeToolbar: [
|
||||||
'gZenCompactModeManager.toggleToolbar()',
|
"gZenCompactModeManager.toggleToolbar()",
|
||||||
'zen-toggle-compact-mode-toolbar',
|
"zen-toggle-compact-mode-toolbar",
|
||||||
'compact-mode-action',
|
"compact-mode-action",
|
||||||
],
|
],
|
||||||
|
|
||||||
// Page actions
|
// Page actions
|
||||||
sendWithMail: ['command:Browser:SendLink', 'send-with-mail', 'page-action'],
|
sendWithMail: ["command:Browser:SendLink", "send-with-mail", "page-action"],
|
||||||
savePage: ['command:Browser:SavePage', 'save-page', 'page-action'],
|
savePage: ["command:Browser:SavePage", "save-page", "page-action"],
|
||||||
printPage: ['command:cmd_print', 'print-page', 'page-action'],
|
printPage: ["command:cmd_print", "print-page", "page-action"],
|
||||||
muteCurrentTab: ['command:cmd_toggleMute', 'mute-current-tab', 'page-action'],
|
muteCurrentTab: ["command:cmd_toggleMute", "mute-current-tab", "page-action"],
|
||||||
showSourceOfPage: ['command:View:PageSource', 'show-source-of-page', 'page-action'],
|
showSourceOfPage: [
|
||||||
showPageInfo: ['command:View:PageInfo', 'show-page-info', 'page-action'],
|
"command:View:PageSource",
|
||||||
|
"show-source-of-page",
|
||||||
|
"page-action",
|
||||||
|
],
|
||||||
|
showPageInfo: ["command:View:PageInfo", "show-page-info", "page-action"],
|
||||||
|
|
||||||
// Visible actions
|
// Visible actions
|
||||||
zoomIn: ['command:cmd_fullZoomEnlarge', 'zoom-in', 'visible-action'],
|
zoomIn: ["command:cmd_fullZoomEnlarge", "zoom-in", "visible-action"],
|
||||||
zoomOut: ['command:cmd_fullZoomReduce', 'zoom-out', 'visible-action'],
|
zoomOut: ["command:cmd_fullZoomReduce", "zoom-out", "visible-action"],
|
||||||
resetZoom: ['command:cmd_fullZoomReset', 'reset-zoom', 'visible-action'],
|
resetZoom: ["command:cmd_fullZoomReset", "reset-zoom", "visible-action"],
|
||||||
|
|
||||||
// History actions
|
// History actions
|
||||||
back: ['command:Browser:Back', 'back', 'history-action'],
|
back: ["command:Browser:Back", "back", "history-action"],
|
||||||
forward: ['command:Browser:Forward', 'forward', 'history-action'],
|
forward: ["command:Browser:Forward", "forward", "history-action"],
|
||||||
stop: ['command:Browser:Stop', 'stop', 'history-action'],
|
stop: ["command:Browser:Stop", "stop", "history-action"],
|
||||||
reload: ['command:Browser:Reload', 'reload', 'history-action'],
|
reload: ["command:Browser:Reload", "reload", "history-action"],
|
||||||
forceReload: ['command:Browser:ReloadSkipCache', 'force-reload', 'history-action'],
|
forceReload: [
|
||||||
|
"command:Browser:ReloadSkipCache",
|
||||||
|
"force-reload",
|
||||||
|
"history-action",
|
||||||
|
],
|
||||||
|
|
||||||
// search actions
|
// search actions
|
||||||
searchInThisPage: ["gLazyFindCommand('onFindCommand')", 'search-in-this-page', 'search-action'],
|
searchInThisPage: [
|
||||||
showNextSearchResult: ["gLazyFindCommand('onFindAgainCommand', false)", 'show-next-search-result', 'search-action'],
|
"gLazyFindCommand('onFindCommand')",
|
||||||
showPreviousSearchResult: ["gLazyFindCommand('onFindAgainCommand', true)", 'show-previous-search-result', 'search-action'],
|
"search-in-this-page",
|
||||||
searchTheWeb: ['command:Tools:Search', 'search-the-web', 'search-action'],
|
"search-action",
|
||||||
|
],
|
||||||
|
showNextSearchResult: [
|
||||||
|
"gLazyFindCommand('onFindAgainCommand', false)",
|
||||||
|
"show-next-search-result",
|
||||||
|
"search-action",
|
||||||
|
],
|
||||||
|
showPreviousSearchResult: [
|
||||||
|
"gLazyFindCommand('onFindAgainCommand', true)",
|
||||||
|
"show-previous-search-result",
|
||||||
|
"search-action",
|
||||||
|
],
|
||||||
|
searchTheWeb: ["command:Tools:Search", "search-the-web", "search-action"],
|
||||||
|
|
||||||
// Tools actions
|
// Tools actions
|
||||||
openMigrationWizard: ['command:cmd_file_importFromAnotherBrowser', 'open-migration-wizard', 'tools-action'],
|
openMigrationWizard: [
|
||||||
quitFromApplication: ['command:goQuitApplication', 'quit-from-application', 'tools-action'],
|
"command:cmd_file_importFromAnotherBrowser",
|
||||||
enterIntoCustomizeMode: ['gCustomizeMode.enter()', 'enter-into-customize-mode', 'tools-action'],
|
"open-migration-wizard",
|
||||||
enterIntoOfflineMode: ['command:cmd_toggleOfflineStatus', 'enter-into-offline-mode', 'tools-action'],
|
"tools-action",
|
||||||
openScreenCapture: ['command:Browser:Screenshot', 'open-screen-capture', 'tools-action'],
|
],
|
||||||
|
quitFromApplication: [
|
||||||
|
"command:goQuitApplication",
|
||||||
|
"quit-from-application",
|
||||||
|
"tools-action",
|
||||||
|
],
|
||||||
|
enterIntoCustomizeMode: [
|
||||||
|
"gCustomizeMode.enter()",
|
||||||
|
"enter-into-customize-mode",
|
||||||
|
"tools-action",
|
||||||
|
],
|
||||||
|
enterIntoOfflineMode: [
|
||||||
|
"command:cmd_toggleOfflineStatus",
|
||||||
|
"enter-into-offline-mode",
|
||||||
|
"tools-action",
|
||||||
|
],
|
||||||
|
openScreenCapture: [
|
||||||
|
"command:Browser:Screenshot",
|
||||||
|
"open-screen-capture",
|
||||||
|
"tools-action",
|
||||||
|
],
|
||||||
|
|
||||||
// Bookmark actions
|
// Bookmark actions
|
||||||
bookmarkThisPage: [
|
bookmarkThisPage: [
|
||||||
"BrowserPageActions.doCommandForAction(PageActions.actionForID('bookmark'), event, this);",
|
"BrowserPageActions.doCommandForAction(PageActions.actionForID('bookmark'), event, this);",
|
||||||
'bookmark-this-page',
|
"bookmark-this-page",
|
||||||
'bookmark-action',
|
"bookmark-action",
|
||||||
],
|
],
|
||||||
openBookmarkAddTool: [
|
openBookmarkAddTool: [
|
||||||
'PlacesUIUtils.showBookmarkPagesDialog(PlacesCommandHook.uniqueCurrentPages)',
|
"PlacesUIUtils.showBookmarkPagesDialog(PlacesCommandHook.uniqueCurrentPages)",
|
||||||
'open-bookmark-add-tool',
|
"open-bookmark-add-tool",
|
||||||
'bookmark-action',
|
"bookmark-action",
|
||||||
|
],
|
||||||
|
openBookmarksManager: [
|
||||||
|
"SidebarController.toggle('viewBookmarksSidebar');",
|
||||||
|
"open-bookmarks-manager",
|
||||||
|
"bookmark-action",
|
||||||
],
|
],
|
||||||
openBookmarksManager: ["SidebarController.toggle('viewBookmarksSidebar');", 'open-bookmarks-manager', 'bookmark-action'],
|
|
||||||
toggleBookmarkToolbar: [
|
toggleBookmarkToolbar: [
|
||||||
"BookmarkingUI.toggleBookmarksToolbar('bookmark-tools')",
|
"BookmarkingUI.toggleBookmarksToolbar('bookmark-tools')",
|
||||||
'toggle-bookmark-toolbar',
|
"toggle-bookmark-toolbar",
|
||||||
'bookmark-action',
|
"bookmark-action",
|
||||||
],
|
],
|
||||||
|
|
||||||
// Open Page actions
|
// Open Page actions
|
||||||
openGeneralPreferences: ['openPreferences()', 'open-general-preferences', 'open-page-action'],
|
openGeneralPreferences: [
|
||||||
openPrivacyPreferences: ["openPreferences('panePrivacy')", 'open-privacy-preferences', 'open-page-action'],
|
"openPreferences()",
|
||||||
openWorkspacesPreferences: ["openPreferences('paneWorkspaces')", 'open-workspaces-preferences', 'open-page-action'],
|
"open-general-preferences",
|
||||||
openContainersPreferences: ["openPreferences('paneContainers')", 'open-containers-preferences', 'open-page-action'],
|
"open-page-action",
|
||||||
openSearchPreferences: ["openPreferences('paneSearch')", 'open-search-preferences', 'open-page-action'],
|
],
|
||||||
openSyncPreferences: ["openPreferences('paneSync')", 'open-sync-preferences', 'open-page-action'],
|
openPrivacyPreferences: [
|
||||||
openTaskManager: ['command:View:AboutProcesses', 'open-task-manager', 'open-page-action'],
|
"openPreferences('panePrivacy')",
|
||||||
openAddonsManager: ['command:Tools:Addons', 'open-addons-manager', 'open-page-action'],
|
"open-privacy-preferences",
|
||||||
openHomePage: ['BrowserHome()', 'open-home-page', 'open-page-action'],
|
"open-page-action",
|
||||||
|
],
|
||||||
|
openWorkspacesPreferences: [
|
||||||
|
"openPreferences('paneWorkspaces')",
|
||||||
|
"open-workspaces-preferences",
|
||||||
|
"open-page-action",
|
||||||
|
],
|
||||||
|
openContainersPreferences: [
|
||||||
|
"openPreferences('paneContainers')",
|
||||||
|
"open-containers-preferences",
|
||||||
|
"open-page-action",
|
||||||
|
],
|
||||||
|
openSearchPreferences: [
|
||||||
|
"openPreferences('paneSearch')",
|
||||||
|
"open-search-preferences",
|
||||||
|
"open-page-action",
|
||||||
|
],
|
||||||
|
openSyncPreferences: [
|
||||||
|
"openPreferences('paneSync')",
|
||||||
|
"open-sync-preferences",
|
||||||
|
"open-page-action",
|
||||||
|
],
|
||||||
|
openTaskManager: [
|
||||||
|
"command:View:AboutProcesses",
|
||||||
|
"open-task-manager",
|
||||||
|
"open-page-action",
|
||||||
|
],
|
||||||
|
openAddonsManager: [
|
||||||
|
"command:Tools:Addons",
|
||||||
|
"open-addons-manager",
|
||||||
|
"open-page-action",
|
||||||
|
],
|
||||||
|
openHomePage: ["BrowserHome()", "open-home-page", "open-page-action"],
|
||||||
|
|
||||||
// History actions
|
// History actions
|
||||||
forgetHistory: ['command:Tools:Sanitize', 'forget-history', 'history-action'],
|
forgetHistory: ["command:Tools:Sanitize", "forget-history", "history-action"],
|
||||||
quickForgetHistory: ['PlacesUtils.history.clear(true)', 'quick-forget-history', 'history-action'],
|
quickForgetHistory: [
|
||||||
clearRecentHistory: ['command:cmd_closeWindow', 'clear-recent-history', 'history-action'],
|
"PlacesUtils.history.clear(true)",
|
||||||
restoreLastSession: ['command:Browser:RestoreLastSession', 'restore-last-session', 'history-action'],
|
"quick-forget-history",
|
||||||
searchHistory: ['command:History:SearchHistory', 'search-history', 'history-action'],
|
"history-action",
|
||||||
manageHistory: ["PlacesCommandHook.showPlacesOrganizer('History')", 'manage-history', 'history-action'],
|
],
|
||||||
|
clearRecentHistory: [
|
||||||
|
"command:cmd_closeWindow",
|
||||||
|
"clear-recent-history",
|
||||||
|
"history-action",
|
||||||
|
],
|
||||||
|
restoreLastSession: [
|
||||||
|
"command:Browser:RestoreLastSession",
|
||||||
|
"restore-last-session",
|
||||||
|
"history-action",
|
||||||
|
],
|
||||||
|
searchHistory: [
|
||||||
|
"command:History:SearchHistory",
|
||||||
|
"search-history",
|
||||||
|
"history-action",
|
||||||
|
],
|
||||||
|
manageHistory: [
|
||||||
|
"PlacesCommandHook.showPlacesOrganizer('History')",
|
||||||
|
"manage-history",
|
||||||
|
"history-action",
|
||||||
|
],
|
||||||
|
|
||||||
// Downloads actions
|
// Downloads actions
|
||||||
openDownloads: ['DownloadsPanel.showDownloadsHistory()', 'open-downloads', 'downloads-action'],
|
openDownloads: [
|
||||||
|
"DownloadsPanel.showDownloadsHistory()",
|
||||||
|
"open-downloads",
|
||||||
|
"downloads-action",
|
||||||
|
],
|
||||||
|
|
||||||
// Sidebar actions
|
// Sidebar actions
|
||||||
showBookmarkSidebar: ["SidebarController.show('viewBookmarksSidebar')", 'show-bookmark-sidebar', 'sidebar-action'],
|
showBookmarkSidebar: [
|
||||||
showHistorySidebar: ["SidebarController.show('viewHistorySidebar')", 'show-history-sidebar', 'sidebar-action'],
|
"SidebarController.show('viewBookmarksSidebar')",
|
||||||
showSyncedTabsSidebar: ["SidebarController.show('viewTabsSidebar')", 'show-synced-tabs-sidebar', 'sidebar-action'],
|
"show-bookmark-sidebar",
|
||||||
reverseSidebarPosition: ['SidebarController.reversePosition()', 'reverse-sidebar', 'sidebar-action'],
|
"sidebar-action",
|
||||||
hideSidebar: ['SidebarController.hide()', 'hide-sidebar', 'sidebar-action'],
|
],
|
||||||
toggleSidebar: ['SidebarController.toggle()', 'toggle-sidebar', 'sidebar-action'],
|
showHistorySidebar: [
|
||||||
zenToggleWebPanels: ['gZenBrowserManagerSidebar.toggle()', 'zen-toggle-web-panels', 'sidebar-action'],
|
"SidebarController.show('viewHistorySidebar')",
|
||||||
zenExpandSidebar: ['gZenVerticalTabsManager.toggleExpand()', 'zen-expand-sidebar', 'sidebar-action'],
|
"show-history-sidebar",
|
||||||
|
"sidebar-action",
|
||||||
|
],
|
||||||
|
showSyncedTabsSidebar: [
|
||||||
|
"SidebarController.show('viewTabsSidebar')",
|
||||||
|
"show-synced-tabs-sidebar",
|
||||||
|
"sidebar-action",
|
||||||
|
],
|
||||||
|
reverseSidebarPosition: [
|
||||||
|
"SidebarController.reversePosition()",
|
||||||
|
"reverse-sidebar",
|
||||||
|
"sidebar-action",
|
||||||
|
],
|
||||||
|
hideSidebar: ["SidebarController.hide()", "hide-sidebar", "sidebar-action"],
|
||||||
|
toggleSidebar: [
|
||||||
|
"SidebarController.toggle()",
|
||||||
|
"toggle-sidebar",
|
||||||
|
"sidebar-action",
|
||||||
|
],
|
||||||
|
zenToggleWebPanels: [
|
||||||
|
"gZenBrowserManagerSidebar.toggle()",
|
||||||
|
"zen-toggle-web-panels",
|
||||||
|
"sidebar-action",
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
const kZenDefaultShortcuts = {
|
const kZenDefaultShortcuts = {
|
||||||
// Split view actions
|
// Split view actions
|
||||||
zenSplitViewGrid: 'Ctrl+Alt+G',
|
zenSplitViewGrid: "Ctrl+Alt+G",
|
||||||
zenSplitViewVertical: 'Ctrl+Alt+V',
|
zenSplitViewVertical: "Ctrl+Alt+V",
|
||||||
zenSplitViewHorizontal: 'Ctrl+Alt+H',
|
zenSplitViewHorizontal: "Ctrl+Alt+H",
|
||||||
zenSplitViewClose: 'Ctrl+Alt+U',
|
zenSplitViewClose: "Ctrl+Alt+U",
|
||||||
|
|
||||||
// Workspace actions
|
// Workspace actions
|
||||||
zenChangeWorkspace: 'Ctrl+Shift+E',
|
zenChangeWorkspace: "Ctrl+Shift+E",
|
||||||
|
|
||||||
// Compact mode actions
|
// Compact mode actions
|
||||||
zenToggleCompactMode: 'Ctrl+Alt+C',
|
zenToggleCompactMode: "Ctrl+Alt+C",
|
||||||
zenToggleCompactModeSidebar: 'Ctrl+Alt+S',
|
zenToggleCompactModeSidebar: "Ctrl+Alt+S",
|
||||||
zenToggleCompactModeToolbar: 'Ctrl+Alt+T',
|
zenToggleCompactModeToolbar: "Ctrl+Alt+T",
|
||||||
|
|
||||||
// manage actions
|
// manage actions
|
||||||
zenToggleWebPanels: 'Alt+P',
|
zenToggleWebPanels: "Alt+P",
|
||||||
};
|
};
|
||||||
|
|
||||||
// Section: ZenKeyboardShortcuts
|
// Section: ZenKeyboardShortcuts
|
||||||
|
|
||||||
const kZKSStorageKey = 'zen.keyboard.shortcuts';
|
const kZKSStorageKey = "zen.keyboard.shortcuts";
|
||||||
const kZKSKeyCodeMap = {
|
const kZKSKeyCodeMap = {
|
||||||
F1: 'VK_F1',
|
F1: "VK_F1",
|
||||||
F2: 'VK_F2',
|
F2: "VK_F2",
|
||||||
F3: 'VK_F3',
|
F3: "VK_F3",
|
||||||
F4: 'VK_F4',
|
F4: "VK_F4",
|
||||||
F5: 'VK_F5',
|
F5: "VK_F5",
|
||||||
F6: 'VK_F6',
|
F6: "VK_F6",
|
||||||
F7: 'VK_F7',
|
F7: "VK_F7",
|
||||||
F8: 'VK_F8',
|
F8: "VK_F8",
|
||||||
F9: 'VK_F9',
|
F9: "VK_F9",
|
||||||
F10: 'VK_F10',
|
F10: "VK_F10",
|
||||||
F11: 'VK_F11',
|
F11: "VK_F11",
|
||||||
F12: 'VK_F12',
|
F12: "VK_F12",
|
||||||
TAB: 'VK_TAB',
|
TAB: "VK_TAB",
|
||||||
ENTER: 'VK_RETURN',
|
ENTER: "VK_RETURN",
|
||||||
ESCAPE: 'VK_ESCAPE',
|
ESCAPE: "VK_ESCAPE",
|
||||||
SPACE: 'VK_SPACE',
|
SPACE: "VK_SPACE",
|
||||||
ARROWLEFT: 'VK_LEFT',
|
ARROWLEFT: "VK_LEFT",
|
||||||
ARROWRIGHT: 'VK_RIGHT',
|
ARROWRIGHT: "VK_RIGHT",
|
||||||
ARROWUP: 'VK_UP',
|
ARROWUP: "VK_UP",
|
||||||
ARROWDOWN: 'VK_DOWN',
|
ARROWDOWN: "VK_DOWN",
|
||||||
DELETE: 'VK_DELETE',
|
DELETE: "VK_DELETE",
|
||||||
BACKSPACE: 'VK_BACK',
|
BACKSPACE: "VK_BACK",
|
||||||
};
|
};
|
||||||
|
|
||||||
var gZenKeyboardShortcuts = {
|
var gZenKeyboardShortcuts = {
|
||||||
init() {
|
init() {
|
||||||
if (!Services.prefs.getBoolPref('zen.keyboard.shortcuts.enabled')) {
|
if (!Services.prefs.getBoolPref("zen.keyboard.shortcuts.enabled")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._initShortcuts();
|
this._initShortcuts();
|
||||||
|
@ -186,7 +361,7 @@ var gZenKeyboardShortcuts = {
|
||||||
}
|
}
|
||||||
this.__savedShortcuts = JSON.parse(data);
|
this.__savedShortcuts = JSON.parse(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Zen CKS: Error parsing saved shortcuts', e);
|
console.error("Zen CKS: Error parsing saved shortcuts", e);
|
||||||
this.__savedShortcuts = {};
|
this.__savedShortcuts = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,16 +382,37 @@ var gZenKeyboardShortcuts = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_parseDefaultShortcut(shortcut) {
|
_parseDefaultShortcut(shortcut) {
|
||||||
let ctrl = shortcut.includes('Ctrl+');
|
let ctrl = shortcut.includes("Ctrl+");
|
||||||
let alt = shortcut.includes('Alt+');
|
let alt = shortcut.includes("Alt+") || shortcut.includes("Option+");
|
||||||
let shift = shortcut.includes('Shift+');
|
let shift = shortcut.includes("Shift+");
|
||||||
let meta = shortcut.includes('Meta+');
|
let meta = shortcut.includes("Meta+") || shortcut.includes("Cmd+");
|
||||||
let key = shortcut.replace(/Ctrl\+|Alt\+|Shift\+|Meta\+/g, '');
|
let key = shortcut.replace(
|
||||||
if (['Tab', 'Enter', 'Escape', 'Space', 'ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(key)) {
|
/Ctrl\+|Alt\+|Option\+|Shift\+|Meta\+|Cmd\+/g,
|
||||||
|
"",
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
[
|
||||||
|
"Tab",
|
||||||
|
"Enter",
|
||||||
|
"Escape",
|
||||||
|
"Space",
|
||||||
|
"ArrowLeft",
|
||||||
|
"ArrowRight",
|
||||||
|
"ArrowUp",
|
||||||
|
"ArrowDown",
|
||||||
|
].includes(key)
|
||||||
|
) {
|
||||||
return { ctrl, alt, shift, meta, key: undefined, keycode: key };
|
return { ctrl, alt, shift, meta, key: undefined, keycode: key };
|
||||||
}
|
}
|
||||||
let isKeyCode = key.length > 1;
|
let isKeyCode = key.length > 1;
|
||||||
return { ctrl, alt, shift, meta, key: isKeyCode ? undefined : key, keycode: isKeyCode ? key : undefined };
|
return {
|
||||||
|
ctrl,
|
||||||
|
alt,
|
||||||
|
shift,
|
||||||
|
meta,
|
||||||
|
key: isKeyCode ? undefined : key,
|
||||||
|
keycode: isKeyCode ? key : undefined,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
_addDefaultShortcuts() {
|
_addDefaultShortcuts() {
|
||||||
|
@ -239,42 +435,50 @@ var gZenKeyboardShortcuts = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_initShortcuts() {
|
_initShortcuts() {
|
||||||
if (window.location.href == 'chrome://browser/content/browser.xhtml') {
|
if (window.location.href == "chrome://browser/content/browser.xhtml") {
|
||||||
console.info('Zen CKS: Initializing shortcuts');
|
console.info("Zen CKS: Initializing shortcuts");
|
||||||
Services.prefs.addObserver(kZKSStorageKey, this._onShortcutChange.bind(this));
|
Services.prefs.addObserver(
|
||||||
Services.prefs.addObserver('zen.keyboard.shortcuts.disable-firefox', this._disableFirefoxShortcuts.bind(this));
|
kZKSStorageKey,
|
||||||
|
this._onShortcutChange.bind(this),
|
||||||
|
);
|
||||||
|
Services.prefs.addObserver(
|
||||||
|
"zen.keyboard.shortcuts.disable-firefox",
|
||||||
|
this._disableFirefoxShortcuts.bind(this),
|
||||||
|
);
|
||||||
this._initSavedShortcuts();
|
this._initSavedShortcuts();
|
||||||
this._disableFirefoxShortcuts();
|
this._disableFirefoxShortcuts();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_disableFirefoxShortcuts() {
|
_disableFirefoxShortcuts() {
|
||||||
let disable = Services.prefs.getBoolPref('zen.keyboard.shortcuts.disable-firefox');
|
let disable = Services.prefs.getBoolPref(
|
||||||
|
"zen.keyboard.shortcuts.disable-firefox",
|
||||||
|
);
|
||||||
if (!disable) {
|
if (!disable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.SessionStore.promiseInitialized.then(() => {
|
window.SessionStore.promiseInitialized.then(() => {
|
||||||
let keySet = document.getElementById('mainKeyset');
|
let keySet = document.getElementById("mainKeyset");
|
||||||
if (!keySet) {
|
if (!keySet) {
|
||||||
throw new Error('Zen CKS: No main keyset found');
|
throw new Error("Zen CKS: No main keyset found");
|
||||||
}
|
}
|
||||||
for (let child of keySet.children) {
|
for (let child of keySet.children) {
|
||||||
if (!child.id.startsWith('zen-key_')) {
|
if (!child.id.startsWith("zen-key_")) {
|
||||||
child.setAttribute('disabled', true);
|
child.setAttribute("disabled", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.info('Remove already exist shortcut keys');
|
console.info("Remove already exist shortcut keys");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_onShortcutChange() {
|
_onShortcutChange() {
|
||||||
console.info('Zen CKS: Shortcut changed');
|
console.info("Zen CKS: Shortcut changed");
|
||||||
this.__savedShortcuts = null;
|
this.__savedShortcuts = null;
|
||||||
this._initSavedShortcuts(true);
|
this._initSavedShortcuts(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
_getCommandAttribute(action) {
|
_getCommandAttribute(action) {
|
||||||
if (action.startsWith('command:')) {
|
if (action.startsWith("command:")) {
|
||||||
return `command="${action.substring(8)}"`;
|
return `command="${action.substring(8)}"`;
|
||||||
}
|
}
|
||||||
return `oncommand="${action}"`;
|
return `oncommand="${action}"`;
|
||||||
|
@ -287,8 +491,7 @@ var gZenKeyboardShortcuts = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const action = kZKSActions[_action][0];
|
const action = kZKSActions[_action][0];
|
||||||
const keycode = shortcut.keycode?.toUpperCase();
|
const key = shortcut.key.toUpperCase();
|
||||||
const key = shortcut.key?.toUpperCase();
|
|
||||||
let modifiers = {
|
let modifiers = {
|
||||||
accel: shortcut.ctrl,
|
accel: shortcut.ctrl,
|
||||||
alt: shortcut.alt,
|
alt: shortcut.alt,
|
||||||
|
@ -298,19 +501,7 @@ var gZenKeyboardShortcuts = {
|
||||||
|
|
||||||
modifiers = Object.keys(modifiers)
|
modifiers = Object.keys(modifiers)
|
||||||
.filter((mod) => modifiers[mod])
|
.filter((mod) => modifiers[mod])
|
||||||
.join(',');
|
.join(",");
|
||||||
|
|
||||||
if (keycode) {
|
|
||||||
const key = kZKSKeyCodeMap[keycode] || keycode;
|
|
||||||
return window.MozXULElement.parseXULToFragment(`
|
|
||||||
<key
|
|
||||||
id="zen-key_${_action}"
|
|
||||||
class="zen-keyboard-shortcut"
|
|
||||||
keycode="${key}"
|
|
||||||
${this._getCommandAttribute(action)}
|
|
||||||
modifiers="${modifiers}"/>
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return window.MozXULElement.parseXULToFragment(`
|
return window.MozXULElement.parseXULToFragment(`
|
||||||
<key
|
<key
|
||||||
|
@ -323,9 +514,9 @@ var gZenKeyboardShortcuts = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_initSavedShortcuts(fromUpdate = false) {
|
_initSavedShortcuts(fromUpdate = false) {
|
||||||
let keySet = document.getElementById('mainKeyset');
|
let keySet = document.getElementById("mainKeyset");
|
||||||
if (!keySet) {
|
if (!keySet) {
|
||||||
throw new Error('Zen CKS: No main keyset found');
|
throw new Error("Zen CKS: No main keyset found");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let action in kZKSActions) {
|
for (let action in kZKSActions) {
|
||||||
|
@ -340,13 +531,13 @@ var gZenKeyboardShortcuts = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._fixMeinKeyset();
|
this._fixMainKeyset();
|
||||||
},
|
},
|
||||||
|
|
||||||
_fixMeinKeyset() {
|
_fixMainKeyset() {
|
||||||
let keySet = document.getElementById('mainKeyset');
|
let keySet = document.getElementById("mainKeyset");
|
||||||
if (!keySet) {
|
if (!keySet) {
|
||||||
throw new Error('Zen CKS: No main keyset found');
|
throw new Error("Zen CKS: No main keyset found");
|
||||||
}
|
}
|
||||||
const parent = keySet.parentElement;
|
const parent = keySet.parentElement;
|
||||||
// We need to re-append the main keyset to the document to make the shortcuts work
|
// We need to re-append the main keyset to the document to make the shortcuts work
|
||||||
|
@ -363,23 +554,20 @@ var gZenKeyboardShortcuts = {
|
||||||
},
|
},
|
||||||
|
|
||||||
shortCutToString(shortcut) {
|
shortCutToString(shortcut) {
|
||||||
let str = '';
|
let str = "";
|
||||||
if (shortcut.ctrl) {
|
if (shortcut.ctrl) {
|
||||||
str += "Ctrl+";
|
str += "Ctrl+";
|
||||||
}
|
}
|
||||||
if (shortcut.alt) {
|
if (shortcut.alt) {
|
||||||
str += 'Alt+';
|
str += AppConstants.platform == "macosx" ? "Option+" : "Alt+";
|
||||||
}
|
}
|
||||||
if (shortcut.shift) {
|
if (shortcut.shift) {
|
||||||
str += 'Shift+';
|
str += "Shift+";
|
||||||
}
|
}
|
||||||
if (shortcut.meta) {
|
if (shortcut.meta) {
|
||||||
str += AppConstants.platform == "macosx" ? "Cmd+" : "Meta+";
|
str += AppConstants.platform == "macosx" ? "Cmd+" : "Meta+";
|
||||||
}
|
}
|
||||||
if (shortcut.keycode) {
|
if (shortcut.key) {
|
||||||
str += shortcut.keycode;
|
|
||||||
} else if (shortcut.key) {
|
|
||||||
// It can be undefined if edited from the settings
|
|
||||||
str += shortcut.key;
|
str += shortcut.key;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue